Repository navigation
fix(runtime): preserve progress and interrupted task context - #1422
mergify[bot] merged 5 commits into
Conversation
|
Queue requested — the merge queue status continues in this comment ↓. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Preserving assistant text in the existing tool-round envelope and serialized budget is the right ownership. The real-DB tests cover interrupted input reaching the next inference without replaying tools. The recovery lookup has two independent blockers. CI is green. I ran the exact SQL with the PR schema and synthetic data on local MatrixOne. I did not rerun the full runtime suite.
b3fcf59 to
c5cc28b
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Preserving progress in the existing tool-round envelope remains well scoped. The new recovery selection gives over-limit sessions a forward path, excludes revoked epochs before selection, and reserves capacity before loading opening bodies. The remaining blocker is the actual database work in ordinary admission. Moving the lookup into the existing statement removes a round trip, but the MatrixOne execution plan still adds a history-sized scan under the Session fence. The inline finding includes a base/head comparison on local MatrixOne 4.2.9.
XuPeng-SH
left a comment
There was a problem hiding this comment.
The three prior findings are addressed. Oversized or obsolete inputs no longer prevent the Session from advancing, and cold opening bodies still require the weighted permit. The locked Session read is back to its existing occupancy and capture checks. On local MatrixOne 4.2.9 I ran the exact new recovery SQL with the v135 DDL. Zero, 5,000 retired, and 5,000 retired plus 5,000 unrelated Runs each read two base rows and one recovery-index row for an empty plan. The prepared statement in the cold case included only eligible earlier inputs and excluded later, revoked, or old-epoch rows. The added SELECT is per fresh root, outside the lock, with no opening body on the healthy path. Recovery remains with the canonical Context owner. The new test asserts scan work, and the docs identify the extra statement and v135 deployment boundary. The local check exercised the SQL and plans independently of the runtime CI suite.
✅ Merged into
|
Capability assessment: Updated: preserves assistant progress content and bounded interrupted-input continuation through the canonical Context owner; recovery binds its captured scope to a measured index outside locked admission. No new provider, execution profile, endpoint or tool authority. See docs/design/runtime-lifecycle.md and docs/design/data-and-storage.md.
Summary
Long tasks lose context when tool-round assembly replaces emitted assistant text with null, or when an executor stops before committing an accepted request to canonical Context. Preserve the text in its existing assistant/tool envelope and restore eligible immutable opening inputs through the existing Context owner.
Interrupted-input recovery now has a bounded forward path. Select recent eligible inputs by owner, Session, unfinished turn and authority epochs before applying the row and byte limits. Recover at most 200 inputs, 32 MiB of stored openings and 256 KiB of serialized input. When accepted input exceeds that window, retain its immutable opening and send an explicit incomplete-history/unknown-effects observation; the next Run can still commit and the Session can continue. This does not recreate uncommitted tool calls or prove that external effects did not occur.
The locked Session admission read retains its original occupancy/capture work. After the opening transaction commits, recovery planning uses the captured Context scope as a literal indexed lookup. Each fresh root adds one body-free metadata query; its recovery base/index reads are bounded independently of retired history. A nonempty plan reserves capacity using exact stored/input byte costs captured at admission, then loads and validates selected complete openings in one query. Resumed executable custody retains its separate existing path. There is no per-opening query or new recovery cursor.
Related issue
Closes #1420.
Related continuity work: #1296 and #1304; this PR does not resolve their other concerns.
MOI prompt/long-command guidance: https://github.com/matrixorigin/matrixflow/pull/22938 (matrixorigin/matrixflow#22935).
Change type
User and compatibility impact
The next inference retains assistant text already emitted before tools and eligible original requests after an interrupted Run. When recovery is incomplete, the model receives that fact and must explain missing context and obtain the needed details before acting. Existing committed history remains authoritative. This is bounded input recovery, not resumption of an expired executor or a guarantee against repeated model wording.
Database compatibility change: Astra advances the existing fresh-schema contract to
2026-12-01-v135.agent_runsaddscontext_recovery_scope,context_recovery_bytes,context_input_bytesand the owner/Session/scope/admission-order index. Earlier schemas are rejected by the existing startup contract. There is no implicit migration or backfill; deploying this build against an existing database requires an explicit fresh-schema cutover. It must not be treated as an in-place, schema-compatible binary update.MOI schema and Offset are unchanged. No public HTTP API, SDK wire model or configuration changes. Assistant text remains subject to the existing serialized Context budget.
Architecture and complexity delta
Verification
uncommitted Run inputs exceed the history admission limit; the same journey passes after the fix.c270d7d57):ASTRA_TEST_DB_IT=1 RUST_MIN_STACK=16777216 cargo test -p astra-runtime --lib interrupted_history_tests:: -- --ignored --test-threads=1 --nocapture: 7 passed on real local MatrixOne 4.2.9 in an isolated fresh v135 database (20.14s).EXPLAIN ANALYZE.make format-checkandgit diff --check: passed.cargo clippy -p astra-services -p astra-runtime --lib --tests -- -D warnings: passed.MEMORIA_SELF_HOSTED_MASTER_ACCESS=1 ASTRA_TEST_DB_IT=1 RUST_MIN_STACK=16777216 cargo test -p astra-runtime --features e2e-hooks --test chat_sql_budget ordinary_chat_and_readonly_rounds_have_bounded_total_sql -- --ignored --exact --nocapture: passed (nine HTTP scenarios, 18–20 total SQL statements, unchanged 20-statement gate, 23.71s).Final checklist