Merge pull request #708 from xMikeMickelson/fix/agent-transcript-path
fix(agent): use session key agentId for transcript path
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
### Fixes
|
### Fixes
|
||||||
- CLI/Update: preserve base environment when passing overrides to update subprocesses. (#713) — thanks @danielz1z.
|
- CLI/Update: preserve base environment when passing overrides to update subprocesses. (#713) — thanks @danielz1z.
|
||||||
- Agents: treat message tool errors as failures so fallback replies still send; require `to` + `message` for `action=send`. (#717) — thanks @theglove44.
|
- Agents: treat message tool errors as failures so fallback replies still send; require `to` + `message` for `action=send`. (#717) — thanks @theglove44.
|
||||||
|
- Agents: route subagent transcripts to the target agent sessions directory and add regression coverage. (#708) — thanks @xMikeMickelson.
|
||||||
|
- Agents/Tools: preserve action enums when flattening tool schemas. (#708) — thanks @xMikeMickelson.
|
||||||
|
|
||||||
## 2026.1.10
|
## 2026.1.10
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,18 @@ function extractEnumValues(schema: unknown): unknown[] | undefined {
|
|||||||
const record = schema as Record<string, unknown>;
|
const record = schema as Record<string, unknown>;
|
||||||
if (Array.isArray(record.enum)) return record.enum;
|
if (Array.isArray(record.enum)) return record.enum;
|
||||||
if ("const" in record) return [record.const];
|
if ("const" in record) return [record.const];
|
||||||
|
const variants = Array.isArray(record.anyOf)
|
||||||
|
? record.anyOf
|
||||||
|
: Array.isArray(record.oneOf)
|
||||||
|
? record.oneOf
|
||||||
|
: null;
|
||||||
|
if (variants) {
|
||||||
|
const values = variants.flatMap((variant) => {
|
||||||
|
const extracted = extractEnumValues(variant);
|
||||||
|
return extracted ?? [];
|
||||||
|
});
|
||||||
|
return values.length > 0 ? values : undefined;
|
||||||
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ const AllMessageActions = [
|
|||||||
"ban",
|
"ban",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
const MessageToolCommonSchema = {
|
const MessageToolCommonSchema = {
|
||||||
provider: Type.Optional(Type.String()),
|
provider: Type.Optional(Type.String()),
|
||||||
media: Type.Optional(Type.String()),
|
media: Type.Optional(Type.String()),
|
||||||
@@ -379,8 +378,7 @@ export function createMessageTool(options?: MessageToolOptions): AnyAgentTool {
|
|||||||
const mediaUrl =
|
const mediaUrl =
|
||||||
readStringParam(params, "media", { trim: false }) ??
|
readStringParam(params, "media", { trim: false }) ??
|
||||||
(parsed.mediaUrls?.[0] || parsed.mediaUrl);
|
(parsed.mediaUrls?.[0] || parsed.mediaUrl);
|
||||||
const replyTo =
|
const replyTo = readStringParam(params, "replyTo") ?? parsed.replyToId;
|
||||||
readStringParam(params, "replyTo") ?? parsed.replyToId;
|
|
||||||
const threadId = readStringParam(params, "threadId");
|
const threadId = readStringParam(params, "threadId");
|
||||||
const buttons = params.buttons;
|
const buttons = params.buttons;
|
||||||
const gifPlayback =
|
const gifPlayback =
|
||||||
@@ -844,8 +842,7 @@ export function createMessageTool(options?: MessageToolOptions): AnyAgentTool {
|
|||||||
const mediaUrl =
|
const mediaUrl =
|
||||||
readStringParam(params, "media", { trim: false }) ??
|
readStringParam(params, "media", { trim: false }) ??
|
||||||
(parsed.mediaUrls?.[0] || parsed.mediaUrl);
|
(parsed.mediaUrls?.[0] || parsed.mediaUrl);
|
||||||
const replyTo =
|
const replyTo = readStringParam(params, "replyTo") ?? parsed.replyToId;
|
||||||
readStringParam(params, "replyTo") ?? parsed.replyToId;
|
|
||||||
return await handleDiscordAction(
|
return await handleDiscordAction(
|
||||||
{
|
{
|
||||||
action: "threadReply",
|
action: "threadReply",
|
||||||
|
|||||||
@@ -416,7 +416,9 @@ export async function agentCommand(
|
|||||||
catalog: catalogForThinking,
|
catalog: catalogForThinking,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const sessionFile = resolveSessionFilePath(sessionId, sessionEntry);
|
const sessionFile = resolveSessionFilePath(sessionId, sessionEntry, {
|
||||||
|
agentId: sessionAgentId,
|
||||||
|
});
|
||||||
|
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
let lifecycleEnded = false;
|
let lifecycleEnded = false;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
buildGroupDisplayName,
|
buildGroupDisplayName,
|
||||||
deriveSessionKey,
|
deriveSessionKey,
|
||||||
loadSessionStore,
|
loadSessionStore,
|
||||||
|
resolveSessionFilePath,
|
||||||
resolveSessionKey,
|
resolveSessionKey,
|
||||||
resolveSessionTranscriptPath,
|
resolveSessionTranscriptPath,
|
||||||
resolveSessionTranscriptsDir,
|
resolveSessionTranscriptsDir,
|
||||||
@@ -189,6 +190,31 @@ describe("sessions", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("uses agent id when resolving session file fallback paths", () => {
|
||||||
|
const prev = process.env.CLAWDBOT_STATE_DIR;
|
||||||
|
process.env.CLAWDBOT_STATE_DIR = "/custom/state";
|
||||||
|
try {
|
||||||
|
const sessionFile = resolveSessionFilePath("sess-2", undefined, {
|
||||||
|
agentId: "codex",
|
||||||
|
});
|
||||||
|
expect(sessionFile).toBe(
|
||||||
|
path.join(
|
||||||
|
path.resolve("/custom/state"),
|
||||||
|
"agents",
|
||||||
|
"codex",
|
||||||
|
"sessions",
|
||||||
|
"sess-2.jsonl",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
if (prev === undefined) {
|
||||||
|
delete process.env.CLAWDBOT_STATE_DIR;
|
||||||
|
} else {
|
||||||
|
process.env.CLAWDBOT_STATE_DIR = prev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it("updateSessionStoreEntry merges concurrent patches", async () => {
|
it("updateSessionStoreEntry merges concurrent patches", async () => {
|
||||||
const mainSessionKey = "agent:main:main";
|
const mainSessionKey = "agent:main:main";
|
||||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-sessions-"));
|
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-sessions-"));
|
||||||
|
|||||||
Reference in New Issue
Block a user