Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(orca): teach the lead that the worker queue is FIFO and how to reorder it

zyjisdog97a1b15c705a
diff --git a/packages/orca-workflow/src/__tests__/orca-bridge-prompt.test.ts b/packages/orca-workflow/src/__tests__/orca-bridge-prompt.test.ts
index 4cf49324af..5a3fc0c647 100644
--- a/packages/orca-workflow/src/__tests__/orca-bridge-prompt.test.ts
+++ b/packages/orca-workflow/src/__tests__/orca-bridge-prompt.test.ts
@@ -10,7 +10,9 @@ describe('renderOrcaLeadSystemPrompt', () => {
const channelDisclosureRule =
'label every delegated task with its actual execution channel: Orca Worker or native subagent.';
const toolSurfaceRule =
- 'Tools: get_workspace_info, create_worker, create_workers, send_to_worker, interrupt_worker, get_worker_queue_status, update_queued_message, cancel_queued_message, merge_queued_messages, update_worker.';
+ 'Tools: get_workspace_info, create_worker, create_workers, send_to_worker, interrupt_worker, get_worker_queue_status, update_queued_message, cancel_queued_message, merge_queued_messages, steer_queued_message, move_queued_message, update_worker.';
+ const queueOrderRule =
+ 'Queue order: the worker queue is FIFO, so a later order runs after the earlier ones. To run an order sooner: steer_queued_message inserts a queued message into the worker\'s current turn, move_queued_message moves it to position 0 (front), and a more urgent order you send while the worker is busy should go out with delivery=steer instead of queueing. merge_queued_messages combines related messages but keeps the earliest position and never reorders. QUEUE_CHANGED from merge_queued_messages means the queue moved under you: re-read get_worker_queue_status and retry.';
const explicitCreationBoundary =
'Use create_worker only when the user explicitly asks to open one new worker, and use create_workers only when the user explicitly asks to open multiple new workers.';
const missingWorkerBoundary =
@@ -99,6 +101,7 @@ describe('renderOrcaLeadSystemPrompt', () => {
const prompt = renderOrcaLeadSystemPrompt(null);
expect(prompt).toContain(toolSurfaceRule);
+ expect(prompt).toContain(queueOrderRule);
expect(prompt).toContain(sendDispatchSignals);
expect(prompt).toContain(createDispatchSignals);
expect(prompt).toContain(interruptDispatchSignals);
diff --git a/packages/orca-workflow/src/orca-bridge-prompt.ts b/packages/orca-workflow/src/orca-bridge-prompt.ts
index afbb170034..d6c99fef07 100644
--- a/packages/orca-workflow/src/orca-bridge-prompt.ts
+++ b/packages/orca-workflow/src/orca-bridge-prompt.ts
@@ -29,9 +29,11 @@ export function renderOrcaLeadSystemPrompt(initialWorker?: OrcaInitialWorkerRef
'An Orca Worker is NEVER a substitute for a subagent. The two are different things: an Orca Worker is a session-level collaborator (its own persistent session, visible in the UI), a subagent is an ephemeral subtask executor inside your own agent. Do NOT open or reuse an Orca Worker to satisfy a subagent request, and do NOT improvise one by spawning processes yourself.',
'Orca Workers are not native subagents. Never use native subagent lifecycle tools — including wait_agent or equivalents — to wait for or manage Orca Workers. Orca reports arrive automatically as new messages. Use those lifecycle tools only for native subagents that the user explicitly requested.',
'',
- 'Tools: get_workspace_info, create_worker, create_workers, send_to_worker, interrupt_worker, get_worker_queue_status, update_queued_message, cancel_queued_message, merge_queued_messages, update_worker.',
+ 'Tools: get_workspace_info, create_worker, create_workers, send_to_worker, interrupt_worker, get_worker_queue_status, update_queued_message, cancel_queued_message, merge_queued_messages, steer_queued_message, move_queued_message, update_worker.',
'(worker_status and read_worker also exist but are for emergency diagnostics only — do NOT use them for normal polling.)',
'',
+ 'Queue order: the worker queue is FIFO, so a later order runs after the earlier ones. To run an order sooner: steer_queued_message inserts a queued message into the worker\'s current turn, move_queued_message moves it to position 0 (front), and a more urgent order you send while the worker is busy should go out with delivery=steer instead of queueing. merge_queued_messages combines related messages but keeps the earliest position and never reorders. QUEUE_CHANGED from merge_queued_messages means the queue moved under you: re-read get_worker_queue_status and retry.',
+ '',
'Messages from workers arrive prefixed with [From Orca Worker <role> (worker_id: <id>)] (role omitted when unknown). Treat them as worker reports or questions, not user messages.',
'',
'How the async workflow works:',