Skip to content

fix(copilot): restore OpenClaw guidance to agent turns - #125997

Merged
steipete merged 2 commits into
mainfrom
steipete/copilot-harness-prompt-guidance-884d5c
Aug 18, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/copilot-harness-prompt-guidance-884d5c

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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 createSystemMessageContent appended only credential safety, workspace bootstrap, and extra context. The fix keeps the Copilot SDK's systemMessage.mode=append contract 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 systemPrompt replacement 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_spawn remains 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

  • Injecting the full buildAgentSystemPrompt would duplicate OpenClaw's complete system prompt inside the Copilot SDK's native prompt instead of supplying only the missing append policy.
  • Relying on tool descriptions would not provide delegation or delivery policy and would not describe capabilities reachable through the hidden catalog.
  • Building from the raw or pre-hook inventory would advertise tools removed by schema projection or before_prompt_build.toolsAllow.
  • Using Copilot-native task guidance would contradict the hard-disabled native task/agent tool catalog and create a second delegation path.

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

  • Pre-fix prompt regression: 1/1 failed because the canonical Copilot session message lacked OpenClaw identity, delegation, visible-reply, and Skill Workshop guidance.
  • After rebasing onto 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.
  • Complete 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 build passed on the exact production tree: 146 Plugin SDK subpaths and 61 plugins.
  • Plugin SDK surface: 4,335 public exports and 2,578 callable exports. The assertion baseline change is shrink-only.
  • Fresh autoreview on the frozen uncommitted bundle: TruffleHog clean, no accepted/actionable findings, overall correct 0.97.

Live behavior

Real OpenAI BYOK execution through the GitHub Copilot SDK on gpt-5.6-luna passed. The prompt requested a user-followed codebase investigation/report without naming sessions_spawn or visible. The model made exactly one spawn with visible=true, described a standalone report deliverable, and returned exactly https://example.test/session/live-proof. Result: 1 passed, 1 skipped; no credentials appeared in output.

Dependency and sibling contract

Direct inspection of openai/codex@b5ea64a203ce1b04629010d3ef0a0d18c3c870a9 confirms developerInstructions is an opaque optional string carried into developer context:

Codex and Copilot are the only production AgentHarness plugins. The sibling sweep found no other extensions/* harness sharing this omission.

Size

  • Production: +323/-220 (net +103). The unavoidable growth adds one canonical final-capability policy owner and Copilot guidance composition while deleting duplicated filtering and visible-reply text.
  • Tests: +641/-126 (net +515).
  • Tooling/ratchets: +5/-4 (net +1).

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.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 18, 2026 20:41
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling extensions: codex extensions: copilot size: XL maintainer Maintainer-authored PR labels Aug 18, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

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 attempt-config.ts; prompt/tool/session consumers importing it closed a cycle through the Copilot attempt graph.

Commit 96bf23b9bcf isolates the unchanged predicate in the leaf attempt-mode.ts module and points all three consumers at that leaf. node --import tsx scripts/check-import-cycles.ts now reports 0 runtime value cycles; the focused 299 tests, git diff --check, and fresh final autoreview (clean, correctness 0.99) are green. This is an architecture-only repair with no prompt or runtime behavior change.

@steipete
steipete force-pushed the steipete/copilot-harness-prompt-guidance-884d5c branch from 96bf23b to 1e2b326 Compare August 18, 2026 21:15
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.
@steipete
steipete force-pushed the steipete/copilot-harness-prompt-guidance-884d5c branch from 1e2b326 to 3c2657a Compare August 18, 2026 21:27
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 3c2657aea655.

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 origin/main:

  • git diff --check — passed.
  • node --import tsx scripts/check-import-cycles.ts — passed, 0 runtime value cycles.
  • pnpm test extensions/copilot/src/attempt.test.ts extensions/copilot/src/prompt-guidance.test.ts extensions/copilot/src/tool-bridge.test.ts src/agents/embedded-agent-runner/run/attempt-prompt-tool-policy.test.ts src/agents/harness/prompt-compaction-hook-helpers.test.ts src/agents/harness/tool-surface-bridge.test.ts extensions/codex/src/app-server/thread-prompt.test.ts src/agents/delegation-guidance.test.ts — passed, 299/299 tests across five routed shards.
  • Fresh branch autoreview against origin/main — TruffleHog clean, no accepted/actionable findings, overall correctness 0.98.

Exact-head CI run 32187830715, attempt 2 is green, including openclaw/ci-gate. Attempt 1 had one unrelated CLI-help child process print its complete output and then hit the 100-second exit deadlock guard; the single bounded infrastructure rerun passed.

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:

  • Installed @github/copilot-sdk 1.0.7 defines append as the default, appends content after SDK-managed sections without removing guardrails, and forwards the same systemMessage wire payload on create and resume (dist/types.d.ts:797-837, dist/client.js:903-931,983-993,1221-1244).
  • Current openai/codex origin/main 88c39c4578 keeps developerInstructions as an optional thread start/resume/fork string, carries it through ConfigOverrides into TurnContext, and emits it as developer context (codex-rs/app-server-protocol/src/protocol/v2/thread.rs:103,392,580; codex-rs/app-server/src/request_processors/thread_processor.rs:1079-1139,1561-1579; codex-rs/core/src/session/turn_context.rs:680; codex-rs/core/src/session/mod.rs:3495-3499).
  • The additive Plugin SDK export is accepted as the generic shared reply-guidance owner; keeping separate Codex/Copilot copies would recreate the drift this repair removes.

The PR body’s live proof remains applicable: a real OpenAI BYOK Copilot SDK turn made exactly one sessions_spawn call with visible=true and returned exactly https://example.test/session/live-proof. The known settled-finalizer BYOK gap remains a separate pre-existing issue and is not hidden by this proof.

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.

@steipete
steipete merged commit b34eb16 into main Aug 18, 2026
393 of 395 checks passed
@steipete
steipete deleted the steipete/copilot-harness-prompt-guidance-884d5c branch August 18, 2026 22:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex extensions: copilot maintainer Maintainer-authored PR scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot harness omits OpenClaw prompt guidance

1 participant