From d77e6d7c67ba6cba1c2cc7c38156d9a07c273768 Mon Sep 17 00:00:00 2001 From: CodeGhost21 <164498022+CodeGhost21@users.noreply.github.com> Date: Wed, 3 Jun 2026 04:01:28 +0530 Subject: [PATCH] fix(orchestrator): force code-repo delegation when reading stalls (#3102) (#3214) --- .../agent_registry/agents/orchestrator/prompt.md | 1 + .../agent_registry/agents/orchestrator/prompt.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/openhuman/agent_registry/agents/orchestrator/prompt.md b/src/openhuman/agent_registry/agents/orchestrator/prompt.md index 6e6e2d782..eb04ce603 100644 --- a/src/openhuman/agent_registry/agents/orchestrator/prompt.md +++ b/src/openhuman/agent_registry/agents/orchestrator/prompt.md @@ -28,6 +28,7 @@ Follow this sequence for every user message: 4. **Does this need other specialised execution?** - If the request is about a **crypto wallet or market action** — balances, transfers, swaps, contract calls, on-chain positions, or trading on a connected exchange — use `delegate_do_crypto`. It enforces read → simulate → confirm → execute and refuses to fabricate chain ids, token addresses, market symbols, or unsupported tools. **Do not** route crypto write operations through `delegate_to_integrations_agent` or `delegate_run_code`. - **Any task that touches a code repository — cloning, exploring, locating files, modifying, building, testing, running shell commands inside it, git operations, pushing branches, opening PRs — uses `delegate_run_code` for the entire task.** Treat "locate where to edit", "investigate the bug", "find the function", "read the file" as code-repo work the moment they're scoped to a repo: they belong inside the same `delegate_run_code` worker as the edit / build / git steps. **Never** route code-repo work through `tools_agent` / `spawn_worker_thread`; those workers lack `edit` / `apply_patch` / `file_write` / `git_operations` / `codegraph_search` and will silently stall in read-mode. `tools_agent` is for *non-repo* work only — ad-hoc shell against the host, web fetch, memory helpers, etc. + - **Do not stall after reading code-repo files.** If you (or a worker you spawned) have *read* files in a repo and have not yet *acted* on them — edited, built, tested, run, or pushed — and the user expects an outcome rather than a summary, that's the signal the task should have gone to `delegate_run_code` from the start. Re-issue the entire task as one `delegate_run_code` call with the full intent and let the code executor own the lifecycle. Do **not** narrate "reading the file…" / "let me check the code…" and then sit idle: in a code-repo task, reading is step zero of execution, not the deliverable. The user does not need to write "use the code executor" — infer it from the request shape (code, repo, file, build, test, run, fix, refactor, push, PR). - If web/doc crawling is required, use `research`. - If the user asks for live/current/time-sensitive facts that are not covered by a direct tool — weather, forecasts, current temperatures, recent news, fresh web facts, or "use Grok/web/live data" — call `research` with a prompt that asks for live sources. Do **not** stop at "on it", and do **not** wait for the exact named provider if it is not wired in. Use the available research tool and then answer with the result. - If complex multi-step decomposition is required, use `delegate_plan`. diff --git a/src/openhuman/agent_registry/agents/orchestrator/prompt.rs b/src/openhuman/agent_registry/agents/orchestrator/prompt.rs index 39c75f586..08cf5a253 100644 --- a/src/openhuman/agent_registry/agents/orchestrator/prompt.rs +++ b/src/openhuman/agent_registry/agents/orchestrator/prompt.rs @@ -237,6 +237,19 @@ mod tests { ); } + // Regression for issue #3102: orchestrator reads files via a worker + // (or directly) and then sits idle instead of delegating to the + // code executor. The fix is the same shape as the live-facts fix — + // a positive "do not stall after reading" sentence in the prompt. + #[test] + fn build_routes_code_repo_work_to_run_code_tool() { + let body = build(&ctx_with(&[])).unwrap(); + assert!(body.contains("Do not stall after reading code-repo files")); + assert!(body.contains("Re-issue the entire task as one `delegate_run_code` call")); + assert!(body.contains("reading is step zero of execution")); + assert!(body.contains("The user does not need to write \"use the code executor\"")); + } + #[test] fn build_emits_delegation_guide_with_collapsed_tool() { let integrations = vec![ConnectedIntegration {