fix: handle default conversation sentinel in headless startup (#1100)

This commit is contained in:
Charles Packer
2026-02-22 23:31:14 -08:00
committed by GitHub
parent 93e5cd2b8c
commit 6253a93c82
2 changed files with 55 additions and 2 deletions

View File

@@ -735,8 +735,10 @@ export async function handleHeadlessCommand(
}
}
// Priority 0: --conversation derives agent from conversation ID
if (specifiedConversationId) {
// Priority 0: --conversation derives agent from conversation ID.
// "default" is a virtual agent-scoped conversation (not a retrievable conv-*).
// It requires --agent and should not hit conversations.retrieve().
if (specifiedConversationId && specifiedConversationId !== "default") {
try {
const conversation = await client.conversations.retrieve(
specifiedConversationId,

View File

@@ -229,6 +229,57 @@ describe("Startup Flow - Integration", () => {
{ timeout: 180000 },
);
test(
"--agent + --conversation default succeeds and stays on default route",
async () => {
let agentIdForTest = testAgentId;
if (!agentIdForTest) {
const bootstrapResult = await runCli(
[
"--new-agent",
"-m",
"haiku",
"-p",
"Say OK",
"--output-format",
"json",
],
{ timeoutMs: 120000 },
);
expect(bootstrapResult.exitCode).toBe(0);
const bootstrapJsonStart = bootstrapResult.stdout.indexOf("{");
const bootstrapOutput = JSON.parse(
bootstrapResult.stdout.slice(bootstrapJsonStart),
);
agentIdForTest = bootstrapOutput.agent_id as string;
testAgentId = agentIdForTest;
}
const result = await runCli(
[
"--agent",
agentIdForTest,
"--conversation",
"default",
"-m",
"haiku",
"-p",
"Say OK",
"--output-format",
"json",
],
{ timeoutMs: 120000 },
);
expect(result.exitCode).toBe(0);
const jsonStart = result.stdout.indexOf("{");
const output = JSON.parse(result.stdout.slice(jsonStart));
expect(output.agent_id).toBe(agentIdForTest);
expect(output.conversation_id).toBe("default");
},
{ timeout: 130000 },
);
test(
"--new-agent with --init-blocks none creates minimal agent",
async () => {