Repository navigation
fix(runtime): preserve summary continuity and correlate MCP settlement - #1031
Conversation
Preserve recognized historical evidence through summary input projection, canonical resume and artifact replacement without forwarding stable instructions or elevating runtime controls. Refs #1024.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Recommendation: REQUEST_CHANGES for exact head 41a579dde9d54d50041fde07a90caa5616a23024 against main at d720c7f4ef3f3393d5950cdaa07a257ac27e959b. This is an author COMMENT review, submitted as XuPeng-SH.
One material finding: [P2] Repeated inline compaction creates an assistant-first Bedrock request. The new summary insertion precedes every retained user round. The Bedrock projection preserves this order, which violates the documented user-first contract for Nova. This affects marked summaries and legacy summaries restored on resume; see the inline comment at crates/astra-turn-core/src/cloud/summary.rs:364. Please preserve historical-evidence semantics while producing a valid provider transcript, and cover the second-generation/resume request at the provider boundary.
I reviewed all 14 changed files and their production callers: summary recognition versus stable instructions/runtime authority; rendered and inline retries; multi-generation commit/resume; artifact persistence/recovery and tool-pair boundaries; provider projection; typed JSON-RPC IDs/envelopes; acknowledgement versus effect settlement; stale-response quarantine; cancellation/completion races and retained execution ownership. I found no additional material issue in these changes. The Astra-side cancellation contract remains process-local ownership and correlated settlement; this review does not claim remote end-to-end termination or cross-replica settlement.
Validation and limits:
- 72 focused local tests passed in disposable, non-root containers with no external networking and read-only source: 71 tests compiled directly from the unchanged exact-head summary/grouping/prompt/helper modules, plus the PR's MCP response-correlation unit test compiled with its unchanged production helpers.
- A separate offline contract fixture compiled the actual exact-head summary source modules and 13 verbatim production Bedrock projection/helper functions. Fresh history starts with
user; both marked second-generation and legacy-resume histories start withassistant. This establishes the request-shape defect against AWS's Nova contract; no live provider rejection was invoked or claimed. make format-checkandgit diff --checkpassed. No product files were edited. I attempted the combined three-crate library rebuild, then stopped it during dependency compilation; I did not locally reproduce all 9,096 tests. Independently inspected CI logs show 5,682 runtime library passes, 3,375 turn-core library passes, and 36 MCP library passes. The three additional turn-core tests behind the combined build'sdb-storefeature are present in source, but were not independently executed here.- Before publication I rechecked identity, open/non-draft state, exact head/base/main, current readable branch requirements and both rulesets, complete check/status/run/job/file/review pagination, and source-app provenance. There are 13 required successes from GitHub Actions app 15368 and two proven scope exclusions (SDK and web): the exact changed-path classifier and successful scope-job log both report those scopes false, and the unchanged workflow guards explain the skipped jobs. No required check is missing, failing, or running. The tested merge
869f29f4e8722d11a8d52f75fdfc7a30f1b2b808has the expected base/head parents and the same tree as this head. There were no existing reviews or inline comments to duplicate. - Optional Harness run 38999627933 completed 18 cases: 17 passed;
flash_rejected_delegation_preserves_parent_toolsfailed because it recorded two rejected, unexecuted delegation attempts where the unchanged case requires exactly one (first missingdescription, then invalid request). The available log does not establish a causal link to this diff or prove flakiness. I did not treat that optional failure as a standalone review gate or rerun it.
The requested change is the provider-transcript defect above. DB/live-provider integration and distributed termination were not exercised locally.
| let mut messages: Vec<Value> = | ||
| Vec::with_capacity(system_messages.len() + history.len() + 1); | ||
| messages.extend(system_messages.iter().cloned()); | ||
| messages.extend(summaries.iter().cloned()); |
There was a problem hiding this comment.
[P2] Preserve a user-first Bedrock transcript when carrying summaries
After a compaction or legacy resume, summary_evidence_message returns role: "assistant", and this insertion puts it before every retained user round. RuntimeSummaryClient forwards that order to the configured provider; build_bedrock_messages extracts system messages and merges adjacent equal roles, but does not add an initial user message. Thus the wire transcript becomes [assistant(summary), user, ...].
For configured Bedrock Nova routes, AWS requires the first message to have the user role. Repeated inline compaction therefore produces an invalid request and the caller records a futile compaction instead of a new summary. An isolated fixture using the exact-head summary modules and verbatim Bedrock projection helpers confirms: fresh history starts with user, while both marked summaries and legacy-resume summaries start with assistant. No live provider was called.
Please preserve historical-evidence semantics while satisfying the provider's history shape, and add a provider-wire regression for second-generation compaction and legacy resume. The new mock-summary-client tests accept this invalid wire shape.
Precede historical assistant evidence with an auxiliary summary task. Exercise the production Bedrock request builder across three generations, marked and legacy resume, PTL retries and tool pairing. Refs #1024; addresses review comment 4301351399.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Recommendation: APPROVE for exact head 1edeec65287bec34ad3f304a82c23750f7552975, against main at d720c7f4ef3f3393d5950cdaa07a257ac27e959b. This is an author COMMENT review as XuPeng-SH.
No remaining material findings. The assistant-first Bedrock/Nova defect from review 5556152039 is addressed. I verified that review's body SHA256 and the inline comment's original head, original line 364, RIGHT side, and original position 55; its remapped current commit_id was not treated as original provenance. This recommendation supersedes the previous recommendation only for the head named above.
The repair adds an auxiliary user task preamble before recognized historical summaries. The evidence remains assistant content, stable instructions remain separate, and the preamble is confined to the summary request. I reviewed the complete three-file repair delta and reused the prior review evidence for the eleven unchanged files, checking their current callers and tests.
- Design: one canonical inline-summary owner; no provider-specific workaround or second history writer. The request becomes user-first while preserving summary evidence through repeated compaction, both legacy envelopes, resume and PTL retry. Rendered summaries and canonical storage retain their existing ownership.
- Database, isolation and resources: no new SQL, schema, network round trip, cache, global mutable state or lock. Artifact writes still precede history replacement and retain user/session ownership and integrity checks; summary execution still uses the existing scoped durable ledger. The repair adds one small message per attempt within the existing bounded retry loop. I make no new throughput, large-concurrency or prompt-cache savings claim.
- Complexity: the production repair is a conditional insertion in the existing projection; the larger addition is regression coverage using the production request builder. No duplicate adapter, lifecycle or status vocabulary was introduced.
- Unhappy paths and boundaries: reviewed malformed/missing summary identity, runtime-authority exclusion, summary-only/orphan histories, tool-pair preservation, PTL exhaustion, unsuccessful summary validation, cancellation around artifact persistence, and resume. The unchanged MCP changes still validate typed JSON-RPC IDs/envelopes before acknowledgement, retain unknown-outcome quarantine, and distinguish notification acknowledgement from correlated effect settlement. No remote end-to-end termination or cross-replica settlement is claimed.
Verification and limits:
- 71 focused source-module tests passed locally, plus an isolated regression fixture covering 50 summary-to-Bedrock projections. The identical fixture fails against the previously reviewed summary source at the assistant-first assertion and passes against this repair. These standalone checks include exact source modules and verbatim Bedrock projection helpers with cached support dependencies; they are not a full workspace rebuild. Containers were non-root, read-only for source, and had no external networking.
- The two new tests,
inline_summary_bedrock_wire_survives_three_generations_and_legacy_resumeandinline_summary_bedrock_wire_accepts_summary_without_user_rounds, exercise the actual production provider builder and both passed in current CI. Localmake format-checkandgit diff --checkpassed; current CI lint passed. - Independently inspected CI logs show 5,684 runtime library passes, 3,375 turn-core library passes and 36 MCP library passes. The combined configuration's three additional
db-storeunit tests are present in source. The owner's reported 9,098 combined local passes were not fully rerun here. DB/live-provider integration and load testing were not performed locally. - Before publication, identity, open/non-draft state, exact head/base/main, readable branch requirements, current rulesets, complete pagination, workflow/source-app provenance and existing review bodies/original anchors were rechecked. Required CI has 13 successful contexts from app 15368, plus two proven SDK/Web scope exclusions. Scope job
117313479025, all fourteen changed paths, the local classifier and unchanged workflow guards agree. The tested merge5527b150f5c6d9455bbc9666982ca0e52b2b6db9has the expected parents and the same tree as this head.
Optional Harness run 39004294061 remains 16/18. flash_child_question_parent_answer exited 3 after 56.83 seconds, below its 90-second outer timeout. Exit 3 is generic API-error classification; unavailable run-tree/execution evidence does not prove that the child never ran or identify a transport/runtime/retrieval cause. introspection_reflection_source_boundary passed tool ordering and successful-result checks but failed introspect depth/horizon predicates and the judge criterion. The unchanged resident schema omits those advanced fields, while the full selected contract supports them; omission defaults to summary/current_turn. Actual arguments and response are withheld, so omitted arguments remain a hypothesis.
Those two causes remain unresolved: neither infrastructure failure nor a PR-induced regression is established, and an indirect regression is not excluded. I evaluated the supplied diagnosis against public logs and unchanged source; I did not access the denied artifact ZIP, rerun remote CI, or use a live model. The optional failures alone are not the review gate. No product files or branches were changed.
Summary
An accepted pre-turn summary is stored as a system message, but the next summary request filtered it out before replacing that history. Carry recognized prior summaries into both inline and rendered requests as historical evidence, including PTL retries, canonical resume and artifact spills. Inline requests put an auxiliary user task before assistant summary evidence so Bedrock Nova receives a user-first transcript. Stable instructions and runtime authority keep their existing boundaries.
Agent Binding HTTP also accepted JSON-RPC results/errors without correlating their response IDs. Require a valid JSON-RPC 2.0 response for the exact typed request ID before accepting acknowledgement or settlement metadata. A stale completion remains an unknown outcome and cannot release the workspace writer.
The issue fixes are separate commits, followed by a focused provider-transcript correction. This PR does not implement #1023's summarization reuse/latency optimization.
Related issue
17b3bc4a7ff8c1e8a2fba0e67c00585475593190; its sender propagation is preserved.Change type
User and compatibility impact
Facts available only in an earlier accepted summary now reach the next summarizer. New summaries carry a versioned internal marker through canonical commit/resume; the exact old producer envelopes remain readable without rewriting their canonical identity. The marker is stripped from provider wire messages. This establishes input continuity, not a model's semantic fidelity.
Agent Binding providers must return the exact JSON-RPC request ID and a valid response envelope. Missing, foreign or malformed responses fail with unknown-outcome handling after a mutating dispatch. Notification acceptance, transport closure and cancellation tokens remain insufficient settlement evidence. Existing cleanup deadlines and quarantine are unchanged.
Architecture and complexity delta
compact_with_memoria, artifact spill, canonical commit/resume, ordinary rmcp and Agent Binding cancellation, dynamic adapters, workspace finalization, MOI HTTP receiver and remote tool provider ownership.6f267fca41e5db5ae92c95da852d3cae2910e63e, already implements protocol-ID propagation and authenticated process-local cooperative cancellation. Do not duplicate that work. The owner chain ismoi/pkg/api/handlers/agent_runtime_gateway.go→agentresource.HandleRuntimeMCP→astraRuntimeToolGateway.Invoke→InvokeAutomationRuntimeTool→AutomationRuntimeSandbox.ExecuteEphemeralSandbox. Cross-replica/ownership-generation routing, provider-owned idempotent settlement readback, remote subprocess termination/wait/reap, absence of late writes and subsequent writer admission still require separate receiving/provider work. The historical cancellation API 500 is not diagnosed by this change. Bug: run cancellation does not reach active MCP calls and can leave ownership unsettled #1016 and matrixflow #18270 must remain open.Verification
Base:
d720c7f4ef3f3393d5950cdaa07a257ac27e959b(main).Head:
1edeec65287bec34ad3f304a82c23750f7552975(original #1024/#1016 commits plus the focused Nova transcript-order correction).Verified published source tree:
ba58fe74b0dcaa1948833b9a8265ddfcb2d5810f, identical to the locally tested commitc2eb8ae859d10e0f1534de22825674cc54b0dc9f. Git API publication changes commit metadata only; the published tree and file blobs are checked against the local tested source and fetched for an empty diff.Commands and results (Rust 1.97.0; builds use
CARGO_BUILD_JOBS=1 CARGO_INCREMENTAL=0 CARGO_TARGET_DIR=/workspace/Astra/target):cargo test --locked --offline -p astra-runtime -p astra-turn-core -p astra-mcp --lib --no-run: passed.cargo clippy --locked --offline -p astra-runtime -p astra-turn-core -p astra-mcp --lib --tests -- -D warnings: passed.make format-checkandgit diff --check origin/main...HEAD: passed.--test-threads=2through the isolated runner described below: runtime 5,684 passed / 106 ignored; turn-core 3,378 passed / 12 ignored; MCP 36 passed / 0 ignored. No failures..build_provider_request_body: three generations, marked and both legacy resume envelopes, PTL retries, semantic/append-only projection, user-first/alternating roles, exact stable system policy, authority projection, paired tools and summary-only/orphaned continuation. The real pre-turn canonical replacement/resume regression remains covered in both projection modes.Existing optional Harness assessment (read-only; no reruns): head run 38999627933 completed 18 cases, 17 passed. The rejected-delegation case recorded two rejected/unexecuted calls instead of one (first missing
description, theninvalid_request); the answer judge accepted its final response. Prior main run 38966120965 has the same failure signature before this PR; base run 38994450827 passed that case and failed a different one. This demonstrates a pre-existing failure, not a measured failure rate or proof that this diff cannot influence it. All other head cases passed, including workspace evidence, editing, provider cache and the two-step execution journey. No oracle or delegation protection was weakened.Tests execute with no external network in a local container, using UID 1000, root-owned sticky
/tmp, read-only source/build/Git inputs and disposable writable test storage. This preserves real workspace ownership checks. Initial broader runs exposed container setup failures (HOME, executable temporary scripts, Cargo test-state storage and linked-worktree Git metadata); these were corrected in the test environment without changing product assertions.Public/runtime entrypoints and unhappy paths:
ServerAgenticLoopHost::maybe_pre_turn_compact: three accepted generations in both semantic and append-only modes, recording client preserves the unique old fact only when actually supplied, positive token reduction, exact retained suffix, paired tool calls/results, current authority preservation, canonical replacement and both legacy/marked resume.compact_with_memoria: rendered input carries prior-summary evidence and excludes stable history instructions/runtime controls. Shared inline/rendered tests retain long and mid-history summaries through PTL retry. Artifact spill carries prior facts and recovery handles across successive replacements; a non-reducing pre-turn replacement leaves history intact.Final checklist