Skip to content

fix(agents): observe native provider prompt egress - #119219

Merged
vincentkoc merged 4 commits into
mainfrom
qa-b3-context-no-meta-leak-20260804
Aug 4, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
qa-b3-context-no-meta-leak-20260804

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

OpenClaw could verify the assembled instruction profile before provider dispatch, but the original observation seam covered only the OpenAI Responses SDK path. Native Codex WebSocket and SSE transports could bypass that evidence boundary, and the PR description overstated which persisted artifacts were prompt-free.

Root Cause And Fix

The OpenAI Responses transport now owns one private, Symbol-based prompt observer that is carried through the existing request options and invoked immediately before each application-level dispatch:

  • OpenAI Responses SDK create
  • native Codex WebSocket send
  • native Codex SSE fetch
  • encrypted-content retry payloads

Each observation records only the egress kind, payload variant, prompt source, expected and observed character counts, and an exact-match boolean. It never records prompt text, hashes, or snippets.

The QA scenario reads only current-run provider.prompt.observed records and proves the final provider-bound prompt matches the assembled instructions. Diagnostic trajectory support bundles still retain context.compiled prompt material by design; they are explicitly excluded from this no-retention assertion.

User Impact

There is no user-facing behavior or public contract change. Maintainers gain exact provider-egress evidence across SDK and native Codex routes without adding prompt content to the bounded observation records.

Evidence

  • Exact signed source head: a17e66d0021b6c762b1ba2900a681c8b800eeb1d.
  • Focused transport, retry, runner, and QA tests: 105/105 passed.
  • Prompt observer regression rerun after the final type fix: 11/11 passed.
  • Local changed gate passed all selected TSGo, lint, format, boundary, dead-code, import-cycle, and repository guard lanes.
  • Structured autoreview and TruffleHog passed with no actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/30918797644.
  • Clean CI completed the dist build and packaged-runtime checks.
  • Final exact-head live openai/gpt-5.4 --fast proof: 1/1 passed.
  • The selected live SDK route recorded 3 responses-sdk/initial observations, 3 exact matches, 0 mismatches, and 28,103 expected/observed characters each. Native WebSocket and SSE routes remain covered by focused transport regressions.
  • Live marker checks passed for history, visible replies, outbound messages, bounded provider observations, and the exact 34-byte artifact; diagnosticTrajectoryPromptRetentionExcluded was true.
  • Live artifacts:
    • .artifacts/qa-e2e/no-meta-live-a17e66d-final/qa-suite-summary.json
    • .artifacts/qa-e2e/no-meta-live-a17e66d-final/qa-evidence.json
    • .artifacts/qa-e2e/no-meta-live-a17e66d-final/qa-suite-report.md

Direct dependency contract check:

  • Codex source head: bb1af235ea2822d7a40f75ef52e4d6a2cde84da2.
  • Responses request shape: codex-rs/codex-api/src/common.rs:251-329.
  • request construction and transport routing: codex-rs/core/src/client.rs:837-924.
  • HTTP dispatch: codex-rs/core/src/client.rs:1437-1459.
  • WebSocket conversion and dispatch: codex-rs/core/src/client.rs:1640-1668.

Production delta is +151/-42 (net +109). Tests and QA add +837/-17 (net +820). The positive production delta is the private cross-transport observation boundary and removal of duplicate SDK-only observation logic.

No changelog entry is needed because this changes internal verification only.

@vincentkoc vincentkoc self-assigned this Aug 4, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 4, 2026 12:32
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: qa-lab size: L maintainer Maintainer-authored PR labels Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 4, 2026, 10:32 AM ET / 14:32 UTC.

ClawSweeper review

What this changes

Adds bounded, run-scoped observations that compare assembled agent instructions with the final OpenAI Responses SDK, native WebSocket, or native SSE request without recording prompt text.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep this maintainer-owned PR open: its transport-edge observer is sound on the inspected SDK and native paths, but the PR description still overstates its no-retention guarantee and the required direct Codex-source contract check is unavailable.

Priority: P2
Reviewed head: a17e66d0021b6c762b1ba2900a681c8b800eeb1d

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The transport implementation is well-covered, but an outstanding privacy-evidence correction and unavailable Codex contract check prevent a higher rating.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored internal verification PR is not subject to the external-contributor proof gate; its reported live run remains supporting evidence.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored internal verification PR is not subject to the external-contributor proof gate; its reported live run remains supporting evidence.
Evidence reviewed 5 items Bounded egress implementation: The observer compares normalized instructions or system/developer input and emits only source, counts, and an equality flag; the inspected native and SDK callers invoke it immediately before dispatch.
Diagnostic retention contradicts the broad PR claim: Trajectory diagnostics record the compiled system prompt and prompt, while the changed QA scenario correctly excludes those bundles from its marker-absence guarantee.
QA regression proves the intended exception: The new flow test intentionally passes with a marker-bearing context.compiled diagnostic record, so only bounded provider.prompt.observed records support the privacy assertion.
Findings 1 actionable finding [P2] Narrow the PR’s privacy claim
Security Needs attention Diagnostic trajectory retains compiled prompts: Compiled prompt diagnostics retain system prompt and prompt text, so the PR must not describe all persisted evidence as prompt-free.

How this fits together

The embedded agent runner assembles system instructions and invokes a provider stream function. OpenAI Responses transports turn that context into SDK, WebSocket, or SSE requests, while the runner records bounded egress metadata in trajectory evidence for QA.

flowchart LR
  A[Embedded agent context] --> B[Provider stream wrapper]
  B --> C[OpenAI Responses transport]
  C --> D{SDK or native egress}
  D --> E[Bounded prompt observation]
  E --> F[Trajectory event evidence]
Loading

Before merge

  • Narrow the PR’s privacy claim (P2) - The changed scenario explicitly excludes diagnostic trajectory bundles because they retain compiled prompts, yet the PR body claims the marker is absent from persisted event evidence. Limit that claim to bounded provider.prompt.observed records and call out the diagnostic exception.
  • Resolve security concern: Diagnostic trajectory retains compiled prompts - Compiled prompt diagnostics retain system prompt and prompt text, so the PR must not describe all persisted evidence as prompt-free.
  • Resolve merge risk (P1) - The PR body says hidden prompt text is absent from persisted evidence, but diagnostic trajectory context retains compiled prompts; reviewers could otherwise accept an incorrect privacy boundary.
  • Resolve merge risk (P1) - The required direct Codex dependency-source review cannot be completed because the sibling checkout is absent and DNS prevents obtaining it.
  • Complete next step (P2) - A maintainer should require the narrow PR-body correction and the missing direct Codex contract check before merge.

Findings

  • [P2] Narrow the PR’s privacy claim — qa/scenarios/agents/instruction-profile-artifact-followthrough-live.yaml:14-16
  • [low] Diagnostic trajectory retains compiled prompts — src/agents/embedded-agent-runner/run/attempt-prompt-observability.ts:98
Agent review details

Security

Needs attention: The implementation records bounded metadata, but the PR’s public privacy claim omits existing diagnostic prompt retention.

PR surface

Source +109, Tests +776, Other +44. Total +929 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 9 151 42 +109
Tests 8 785 9 +776
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 52 8 +44
Total 18 988 59 +929

Review metrics

Metric Value Why it matters
Runtime, QA, and test delta runtime +151/-42; QA scenario +52/-8; tests +785/-9 The new verification boundary is substantially test-backed, while its privacy claim must match the retained diagnostic path before merge.

Stored data model

Persistent data-model change detected: persistent cache schema: packages/ai/src/transports/openai-responses-prompt-observer-internal.ts, persistent cache schema: packages/ai/src/transports/openai-responses-prompt-observer.test.ts, serialized state: extensions/qa-lab/src/scenario-flow-runner.test.ts, serialized state: packages/ai/src/providers/openai-chatgpt-responses.retry.test.ts, serialized state: src/agents/embedded-agent-runner/provider-prompt-state.test.ts, serialized state: src/agents/embedded-agent-runner/provider-prompt-state.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Correct the evidence boundary before merge (recommended)
    Update the PR description to limit non-retention claims to bounded provider observations and name diagnostic trajectory retention as out of scope.

Technical review

Best possible solution:

Keep the transport-egress observer, but describe its guarantee as applying only to bounded provider.prompt.observed records and explicitly exclude diagnostic trajectory exports that retain compiled prompts.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a user bug reproduction: this PR adds internal verification. Source inspection does directly show that diagnostic trajectory context retains the prompt text excluded by the scenario.

Is this the best way to solve the issue?

Unclear: transport-edge observation is the correct owner boundary on inspected paths, but the PR body is too broad and direct Codex protocol-source verification is unavailable.

Full review comments:

  • [P2] Narrow the PR’s privacy claim — qa/scenarios/agents/instruction-profile-artifact-followthrough-live.yaml:14-16
    The changed scenario explicitly excludes diagnostic trajectory bundles because they retain compiled prompts, yet the PR body claims the marker is absent from persisted event evidence. Limit that claim to bounded provider.prompt.observed records and call out the diagnostic exception.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 52954a1fa8f4.

Labels

Label justifications:

  • P2: This is a bounded internal verification improvement with an unresolved privacy-evidence claim, not a user-facing outage.
  • merge-risk: 🚨 security-boundary: The proposed public evidence claim could misstate where compiled prompts remain persisted in diagnostics.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This MEMBER-authored internal verification PR is not subject to the external-contributor proof gate; its reported live run remains supporting evidence.

Evidence

Security concerns:

  • [low] Diagnostic trajectory retains compiled prompts — src/agents/embedded-agent-runner/run/attempt-prompt-observability.ts:98
    Compiled prompt diagnostics retain system prompt and prompt text, so the PR must not describe all persisted evidence as prompt-free.
    Confidence: 0.99

What I checked:

Likely related people:

  • petersteinberger: Recent factory and native Codex transport refactors own the SDK/native egress surface this PR instruments. (role: recent Responses transport contributor; confidence: high; commits: 9588a10f122d, b0525e1a70b6, cb16d739cfda; files: packages/ai/src/transports/openai-responses-client.ts, packages/ai/src/providers/openai-chatgpt-responses.ts)
  • joshavant: The prior substantive prompt retry-state implementation dates to this agent-runner change. (role: prompt-state contributor; confidence: high; commits: e07de4c56159; files: src/agents/embedded-agent-runner/provider-prompt-state.ts)
  • vincentkoc: Recent provider-diagnostics history overlaps the observation and trajectory evidence boundary. (role: recent diagnostics contributor; confidence: medium; commits: 1130f30445c4; files: packages/ai/src/transports/openai-responses-client.ts, src/agents/embedded-agent-runner/provider-prompt-state.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Update the PR body to scope the no-retention guarantee to bounded provider observations.
  • Obtain a direct sibling Codex-source contract check before making a native-Codex merge verdict.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-04T13:12:12.706Z sha e7c8be8 :: found issues before merge. :: [P1] Observe the native Codex request path | [P1] Do not treat filtered observer records as all event evidence
  • reviewed 2026-08-04T14:09:58.712Z sha 1438eee :: found issues before merge. :: [P2] Align the public evidence claim with retained diagnostics

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 4, 2026
* origin/main:
  chore(tui): add Gateway boundary PTY coverage (#119191)
  fix(telegram): route reactions to their originating forum topics
  test(gateway): isolate scheduled service timers (#119218)
  test(qa): cover Canvas agent and node controls (#119047)
  fix(cli): avoid repeated migration scans during local agent turns (#119051)
  fix(gateway): keep agents list on prepared model facts (#119208)
  fix(telegram): retry update offset persistence
  fix(ci): accept profiled partial Kova gates (#119121)
@vincentkoc vincentkoc changed the title fix(agents): verify provider prompt context without leaking it fix(agents): observe native provider prompt egress Aug 4, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

ClawSweeper before-merge items are resolved at a17e66d0021b6c762b1ba2900a681c8b800eeb1d:

  1. Privacy claim narrowed: the PR body now limits the no-retention guarantee to bounded, current-run provider.prompt.observed records plus history, visible replies, outbound messages, and the scenario artifact.
  2. Diagnostic retention named explicitly: trajectory support bundles retain context.compiled prompt material by design and are excluded from this assertion.
  3. Security/merge-risk wording corrected: the PR no longer claims all persisted event evidence is prompt-free.
  4. Direct Codex source contract checked: sibling Codex head bb1af235ea2822d7a40f75ef52e4d6a2cde84da2; request shape at codex-rs/codex-api/src/common.rs:251-329, construction/routing at codex-rs/core/src/client.rs:837-924, HTTP dispatch at codex-rs/core/src/client.rs:1437-1459, and WebSocket conversion/dispatch at codex-rs/core/src/client.rs:1640-1668.
  5. Maintainer next step completed: exact-head CI is green, including dist build and packaged artifact checks; the final live proof is recorded in the updated PR body, and repo-native review artifacts are restamped and validated at the reviewed head.

No implementation change was required for the retained diagnostic trajectory path; that path is intentionally outside this bounded QA privacy contract.

@vincentkoc
vincentkoc merged commit a54bec7 into main Aug 4, 2026
126 checks passed
@vincentkoc
vincentkoc deleted the qa-b3-context-no-meta-leak-20260804 branch August 4, 2026 14:46
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 4, 2026
* origin/main:
  fix(agents): protect private memory in shared chats (#119198)
  perf(cli): skip absent gateway workspace dotenv (#119227)
  fix(agents): observe native provider prompt egress (#119219)
  fix(feishu): report bot identity retry failures (#102185)
  fix(memory): load configured providers for CLI search (#119186)
  fix(discord): count retained speech bytes
  test(discord): isolate exact speech overflow
  test(discord): cover exact speech overflow
  fix(discord): bound realtime exact speech
vincentkoc added a commit that referenced this pull request Aug 4, 2026
* origin/main:
  fix(agents): protect private memory in shared chats (#119198)
  perf(cli): skip absent gateway workspace dotenv (#119227)
  fix(agents): observe native provider prompt egress (#119219)
  fix(feishu): report bot identity retry failures (#102185)
  fix(memory): load configured providers for CLI search (#119186)
  fix(discord): count retained speech bytes
  test(discord): isolate exact speech overflow
  test(discord): cover exact speech overflow
  fix(discord): bound realtime exact speech
vincentkoc added a commit that referenced this pull request Aug 4, 2026
…licy-config-20260804

* origin/main:
  perf(cli): skip absent gateway workspace dotenv (#119227)
  fix(agents): observe native provider prompt egress (#119219)
  fix(feishu): report bot identity retry failures (#102185)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
* fix(agents): observe final provider prompt egress

* fix(agents): observe native provider prompt egress

* test(agents): type native prompt observer models
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
* origin/main:
  fix(agents): protect private memory in shared chats (openclaw#119198)
  perf(cli): skip absent gateway workspace dotenv (openclaw#119227)
  fix(agents): observe native provider prompt egress (openclaw#119219)
  fix(feishu): report bot identity retry failures (openclaw#102185)
  fix(memory): load configured providers for CLI search (openclaw#119186)
  fix(discord): count retained speech bytes
  test(discord): isolate exact speech overflow
  test(discord): cover exact speech overflow
  fix(discord): bound realtime exact speech
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: qa-lab maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant