Repository navigation
fix(agents): stabilize message tool definitions across session turns - #181279
Conversation
Discover message actions from persisted session delivery and scheduled account bindings, preserving non-default capabilities across recovery and announce turns. Keep current-prompt reactions gated by live turn authority. Exclude persistence-only display metadata from prompt history fingerprints.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Codex review: needs changes before merge. What this changesThis PR builds message definitions from session facts and excludes persistence-only display metadata from prompt history fingerprints. Example: A fleet parent resumes after a Gateway restart through a WebChat-sourced announcement.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain This maintainer-authored PR addresses a current prompt stability defect, but native scheduled-account discovery and a diff-caused snapshot test failure need correction. Priority: P2 Before merge
Findings
Provenance
Agent review detailsHow this fits togetherAgent tool assembly projects session and channel configuration into provider-facing definitions, while message invocation separately resolves current authority before channel effects. flowchart TD
A[Session and configuration] --> B[Message discovery]
B --> C[Provider tool definition]
C --> D[Model tool call]
D --> E[Live turn authority]
E --> F[Channel action]
A --> G[History fingerprints]
Technical reviewBest possible solution: Keep session-based definitions, preserve native scheduled requester account discovery, and update the snapshot reconstruction expectation. Do we have a high-confidence way to reproduce the issue? Current-main discovery consumes changing ingress facts, and the PR reports red-on-base regressions plus comparative Gateway restart results; this review executed no target code. Is this the best way to solve the issue? Separating session discovery from live invocation authority is the appropriate owner-level fix, provided the existing native scheduled-account contract survives the cutover. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9c05ca0d6ece. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +94, Tests +473, Docs +3. Total +570 across 14 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 22, 2026, 11:54 PM ET / October 23, 2026, 03:54 UTC. |
|
The snapshot reconstruction finding is fixed in a2b1b4f, with all 13 snapshot tests passing and final-head CI green. Follow-up from the completed review: preserve saved native Discord requester-account discovery for scheduled jobs with an unknown caller origin and a different delivery account. Per the scoped landing instruction, this capability-availability edge case is deferred; the review reports no security finding. It remains separate from this prompt-prefix repair. |
…penclaw#181279) Stabilize message tool definitions across CLI, restart recovery, and subagent announcement turns by deriving discovery from session and config facts. Preserve persisted delivery and scheduled creator accounts while keeping live execution authority checks. Exclude persistence-only display metadata from prompt-history fingerprints. Align the Discord snapshot reconstruction expectation with the regenerated message override. The failure reproduced before the repair; all 13 snapshot tests pass after it. Coordinator proof covers 288 focused tests and a live restart comparison, and CI is green for the final head.
What Problem This Solves
Sub-agent fleet parents lost large parts of their prompt cache around Gateway restarts and child announcements. Tapped Responses request bodies from one parent session showed two causes.
1. The
messagetool definition was built from the current turn's source.message-tool-execution.tspassed the turn's channel, message, sender and authority into discovery. An operator-CLI turn advertised"Supports actions: broadcast, send."with enum[broadcast, send]. The restart-recovered and WebChat-sourced announce turns of the same session advertised"Supports actions: react, send. When the current WebChat prompt permits reactions, react…"with enum[react, send], and the definition flipped back afterwards. Each flip broke the cached prefix:This violates the prompt-prefix contract: tool definitions may depend only on session and config facts.
2. A false "history must be append-only" warning.
message 31 (assistant) differs from the previous request; history must be append-only; changed fields: envelope.otherwas caused by persistence addingdisplay: false(transcript-visibility.ts). The tapped provider bodies were byte-identical; the Responses converter omits that field.User Impact
Fleet parents retain a stable message-tool definition across CLI, recovery, and child-announcement turns, preserving prompt-cache reuse. Persistence-only visibility metadata no longer triggers false history-rewrite warnings. No migration or operator action is required.
Why This Change Was Made
messagetool discovery uses session and config facts only, keeping the session's persisted delivery account and the scheduled creator account, so non-default-account capabilities such as iMessageeditfor a boundopsaccount are preserved. Per-turn facts no longer shape the definition. WebChat reaction guidance is stable, and execution checks the current grant, reporting an unavailable reaction clearly. Both synchronous and async factories are covered.displayfield. A regression asserts byte-identical output from the real Responses converter.Evidence
agent-tools.prefix-stability.test.ts"keeps message definitions stable across CLI…" (2 failed), andprompt-cache-observability.history.test.ts"keeps recovered coordination history stable" (1 failed,prefix changed within session).message-tool.scheduled-writes(10, including the preserved iMessage non-default-account case),message-tool-discovery(40), prompt-cache history (43), current-prompt reaction (18),message-tool-execution(68), discovery enumeration (3),message-tool(98).pnpm prompt:snapshots:checkreports snapshots current; format, lint and targeted typechecks pass.kill -9while two fleet parents were still in their first turn, with every Responses body recorded:messagedefinition flip on the recovery turn and back on the yield turn, cache drops of 43K→26K and 63K→0, and the append-only warning.messagedefinition across every consecutive request of both parents.Follow-up, not in this PR: settle-wake requests switch
prompt_cache_keyto anopenclaw-webchat-…affinity key and back. That's a separate cache-identity owner, handled in its own PR.CI follow-up: the snapshot reconstruction test still expected Discord's old override list (
sessions_spawnonly), while the regenerated catalog correctly contains bothmessageandsessions_spawn. The exact list expectation is updated without weakening the assertion. The failure reproduced on Crabbox before the repair; all 13 tests intest/scripts/prompt-snapshots.test.tspass afterward.