Skip to content

fix(runtime): preserve summary continuity and correlate MCP settlement - #1031

Merged
XuPeng-SH merged 3 commits into
mainfrom
fix/summary-continuity-mcp-settlement
Oct 17, 2026
Merged

XuPeng-SH merged 3 commits into
mainfrom
fix/summary-continuity-mcp-settlement

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

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

Change type

  • Feature
  • Bug fix
  • Documentation
  • Refactor or performance improvement
  • Test
  • Build, CI, or maintenance

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

  • Canonical owners extended: shared turn-core historical-summary recognition/projection; existing pre-turn/artifact producers and canonical continuation/provider projections; Agent Binding HTTP response decoder. No new state machine, service, persistence table or timeout policy.
  • Existing implementations/callers searched: pre-turn compaction, 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.
  • Superseded behavior removed: blanket omission of recognized historical summaries; uncorrelated response acknowledgement. Existing inference admission is unchanged; only the inference client is injected in offline host tests.
  • External boundary: matrixflow #18920, checked open/draft at 6f267fca41e5db5ae92c95da852d3cae2910e63e, already implements protocol-ID propagation and authenticated process-local cooperative cancellation. Do not duplicate that work. The owner chain is moi/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 commit c2eb8ae859d10e0f1534de22825674cc54b0dc9f. 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-check and git diff --check origin/main...HEAD: passed.
  • Built library test executables run with --test-threads=2 through 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..
  • Provider-boundary regressions call the actual production 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.
  • Full workspace, optional database/live-provider and remote end-to-end suites were not run.

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, then invalid_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.
  • Real local Agent Binding HTTP and executor ownership path: accepted/rejected/hanging cancellation notifications, duplicate cancellation, delayed completion and fake late write, stale/missing/typed-mismatched IDs, malformed envelopes, unrelated SSE events, HTTP errors and disconnect. Matching settlement admits the next writer; foreign settlement leaves quarantine. Existing preflight, interaction-resume, dynamic-adapter and non-cooperative cleanup regressions remain in the suite.
  • Database verification: not applicable; no database/schema changes or live database calls. No production/shared services, paid inference, remote process probes or deployment acceptance were used. Remote end-to-end termination remains unvalidated.

Final checklist

  • I added or updated tests at the layer that owns the behavior.
  • I updated design documentation for contract changes.
  • I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information.
  • The PR title follows the repository's Conventional Commit format.

Preserve recognized historical evidence through summary input projection, canonical resume and artifact replacement without forwarding stable instructions or elevating runtime controls. Refs #1024.
Reject stale or malformed Agent Binding replies without releasing workspace ownership. Preserve cancellation notification and cleanup behavior from #1017; document the external receiving/provider settlement boundary. Refs #1016.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with assistant. This establishes the request-shape defect against AWS's Nova contract; no live provider rejection was invoked or claimed.
  • make format-check and git diff --check passed. 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's db-store feature 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 869f29f4e8722d11a8d52f75fdfc7a30f1b2b808 has 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_tools failed because it recorded two rejected, unexecuted delegation attempts where the unchanged case requires exactly one (first missing description, 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());

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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 XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_resume and inline_summary_bedrock_wire_accepts_summary_without_user_rounds, exercise the actual production provider builder and both passed in current CI. Local make format-check and git diff --check passed; 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-store unit 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 merge 5527b150f5c6d9455bbc9666982ca0e52b2b6db9 has 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant