Repository navigation
fix(copilot): restore OpenClaw guidance to agent turns - #125997
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
The deterministic architecture gate failed at https://github.com/openclaw/openclaw/actions/runs/32183681862/job/95862597519 because the raw-run predicate lived in orchestration-heavy Commit 96bf23b9bcf isolates the unchanged predicate in the leaf |
96bf23b to
1e2b326
Compare
Copilot append-mode system messages included credential safety, workspace bootstrap, and extra context but omitted OpenClaw delegation and reply-delivery policy. Build guidance from the final policy-filtered tool surface so visible delegated work, Skill Workshop, and source replies follow the same behavior as Codex.
The CI architecture gate detected a cycle through attempt-config and prompt-guidance. Isolate raw-run mode detection in a leaf module.
1e2b326 to
3c2657a
Compare
|
Land-ready proof for exact head The root cause is prompt/tool policy drift at the Copilot session-setup owner: ordinary turns received callable bridged tools, but the append-mode system message omitted matching delegation, visible-reply, and Skill Workshop policy. The canonical fix derives tools and guidance from one final policy-filtered capability inventory, including hidden Tool Search/Code Mode entries. The follow-up commit preserves that design while moving raw-run detection to a leaf module to remove the import cycle. Local proof after the final rebase onto
Exact-head CI run 32187830715, attempt 2 is green, including ClawSweeper exact-head review run 32188116055 found no patch defect, marked the patch correct and security-cleared, and named one Rank-up move: inspect the Copilot SDK and sibling Codex contracts directly. Applied:
The PR body’s live proof remains applicable: a real OpenAI BYOK Copilot SDK turn made exactly one Rebase accounting is unchanged: production +323/-220 judged (net +103), tests +641/-126, tooling/ratchets +5/-4. No paths or behavior outside this PR were changed. |
|
Merged via squash.
|
* fix(copilot): add OpenClaw prompt guidance Copilot append-mode system messages included credential safety, workspace bootstrap, and extra context but omitted OpenClaw delegation and reply-delivery policy. Build guidance from the final policy-filtered tool surface so visible delegated work, Skill Workshop, and source replies follow the same behavior as Codex. * fix(copilot): break prompt guidance import cycle The CI architecture gate detected a cycle through attempt-config and prompt-guidance. Isolate raw-run mode detection in a leaf module.
Closes #125996
AI-assisted: prepared with Codex; the maintainer reviewed the implementation, tests, dependency contract, and live behavior.
What Problem This Solves
Fixes an issue where Copilot-runtime users could receive bridged OpenClaw tools without the matching OpenClaw tool, delegation, visible-reply, or Skill Workshop policy on ordinary agent turns. The capability existed, but the prompt did not tell the model how to use it, creating silent or incorrect routing risk for delegated work and source replies.
Why This Change Was Made
Copilot's
createSystemMessageContentappended only credential safety, workspace bootstrap, and extra context. The fix keeps the Copilot SDK'ssystemMessage.mode=appendcontract and does not inject the full OpenClaw system prompt.The shared harness owner now atomically applies prompt-time tool filtering to both direct tools and the hidden Tool Search/Code Mode catalog after schema projection. Prompt hooks lazily build guidance from the final callable capabilities, while a hook-provided
systemPromptreplacement remains authoritative. Copilot-specific guidance then composes OpenClaw identity, Skill Workshop, delegation, visible-reply, credential-safety, workspace, and extra-context sections. Codex and Copilot reuse the same visible-source reply wording.Copilot-native task and agent tools remain hard-disabled through
SessionConfig.availableTools;sessions_spawnremains the delegation mechanism.Provenance: the omission was introduced with the Copilot attempt split in #114035 (
299f5a4941d2) by @steipete and merged by @steipete on 2026-07-26. Later prompt edits carried the limited append content forward.Alternatives rejected
buildAgentSystemPromptwould duplicate OpenClaw's complete system prompt inside the Copilot SDK's native prompt instead of supplying only the missing append policy.before_prompt_build.toolsAllow.User Impact
Copilot agent turns now receive guidance that matches the exact capabilities callable on that turn. User-followed delegated work is directed to a visible session and returns its link; hidden work, source replies, message-tool delivery, and Skill Workshop guidance follow the same OpenClaw policy boundaries as the Codex harness.
Evidence
Regression and focused proof
a57d9b506081505476d899af9b2073d57b0bd674: the eight-file focused suite passed 299/299 tests across Copilot prompt/attempt/tool bridge, shared prompt tool policy and hook composition, Codex thread prompting, and delegation guidance.node scripts/check-changed.mjs -- <all changed files>passed before publication, including production/test types, formatting, lint, guards, cycles, and Plugin SDK surface checks. The conflict-free rebase changed no behavior.pnpm buildpassed on the exact production tree: 146 Plugin SDK subpaths and 61 plugins.Live behavior
Real OpenAI BYOK execution through the GitHub Copilot SDK on
gpt-5.6-lunapassed. The prompt requested a user-followed codebase investigation/report without namingsessions_spawnorvisible. The model made exactly one spawn withvisible=true, described a standalone report deliverable, and returned exactlyhttps://example.test/session/live-proof. Result: 1 passed, 1 skipped; no credentials appeared in output.Dependency and sibling contract
Direct inspection of
openai/codex@b5ea64a203ce1b04629010d3ef0a0d18c3c870a9confirmsdeveloperInstructionsis an opaque optional string carried into developer context:codex-rs/app-server-protocol/src/protocol/v2/thread.rs:103,392,580codex-rs/app-server/src/request_processors/thread_processor.rs:1056-1141codex-rs/core/src/session/turn_context.rs:680codex-rs/core/src/session/mod.rs:3494-3500Codex and Copilot are the only production AgentHarness plugins. The sibling sweep found no other
extensions/*harness sharing this omission.Size
Known separate gap
The existing settled-finalizer live smoke can report capability activity after a successful tool turn. This is a separate pre-existing finalization issue and is intentionally not weakened or changed here; the prompt behavior above is independently green, and a separate follow-up has been recorded.