fix: handle default conversation sentinel in headless startup (#1100)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user