Repository navigation
fix(runtime): simplify context recovery and tool observation - #1295
Conversation
|
This pull request is merged. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of b6cfc48 against merge base 71da5a7.
Findings: no material blocker found. Recommendation: approve.
Reviewed the complete 38-file change map, with implementation, tests and documentation assessed separately.
- The design uses the existing preparation, canonical rewrite, artifact store/reader, dispatch deadline and callback owners. The removed post-response budget branch could abandon a selected batch; settlement now precedes preparation recovery. No parallel lifecycle, table or ordinary-turn SQL observer is introduced. The one transient measurement-applicability fact preserves paid usage while invalidating an obsolete pressure floor.
- Both preparation and streamed typed context-window failures reach the authorized lossless artifact owner when exact deduplication cannot help. Reader/writer availability, canonical permits, owner/session scope, bounded retries, cancellation and original-error precedence remain intact. The two concrete context findings recorded in #1290 have regression coverage.
- Task observation shares the millisecond contract, policy cap and admitted absolute cutoff, with settlement time reserved separately. Observation timeout/cancellation does not claim the task or parent stopped. Callback retries preserve the original request identity and recorded result rather than rerunning the command.
- Removing executor-lifetime output accounting retires the duplicate gating path while retaining per-call bounds, full-file size checks, ranged reads, redaction and delivered evidence. Cached requests retain current full tool schemas and stable system instructions; current authority changes still apply. Historical summaries remain evidence below the instruction prefix.
- Tests exercise the agent loop, actual observation/process lifetime and provider message builders, not just the new flags. The CI fixture corrections use typed cancellation/timeout and establish the held-child wait before releasing it, without increasing its observation budget. Documentation accurately describes bounded recovery and remaining limits.
Validation performed in this review on machine 57, using binaries rebuilt from the reviewed worktree: 27 Runtime + 17 CLI + 13 context/schema contract tests passed, with no ignored tests in those selections; diff whitespace/conflict-marker check passed. The CLI selection includes all three repaired CI failures. Current hosted checks are complete: 36 success, 4 skipped and 1 neutral, with no failures.
Previously recorded real Server/isolated MatrixOne, public HTTP SQL and unsuppressed TSan evidence was reconciled against the source manifest: 36 paths are byte-identical, and the only subsequent changes are the two inspected test-fixture files. Those database and TSan runs were not repeated in this review.
Comment closure: the PR has no existing review threads or reviewer comments. The two context defects in the #1290 follow-up comment are addressed. Original external-runner cleanup, browser/cross-instance database outage, child-envelope and stale-binding incidents were not replayed, and this PR explicitly uses Refs rather than claiming the whole issue closed. Wire-shape checks do not establish a live provider cache-hit rate or production capacity.
Review performed by the current agent under the repository review_changes guide, without subagents or source edits.
GitHub rejected the APPROVE event because the authenticated account is also the PR author. This is a COMMENT review recording the recommendation above; it is not a formal GitHub approval.
Capability assessment: Unchanged: Repairs existing context recovery, cached request assembly and task observation contracts; capability profiles, permission scopes and MOI Gate requirements remain accurate.
Summary
A high provider input sample could trigger compaction after tools were selected, skip their settlement, then trigger another archive on the next iteration even after history had shrunk. Settle the current tool batch first and give preparation one recovery path: exact deduplication, optional semantic summary, then authorized durable history storage, remeasuring between steps.
Related issue
Refs #1290. The original external-runner cleanup, browser/cross-instance database outage, child envelope and stale provider-binding incidents were not replayed; this PR does not claim those incidents closed. #1291 will be handled as a separate follow-up.
Change type
User and compatibility impact
Long tasks can continue after useful context recovery without abandoning selected tools or repeatedly archiving an already-relieved history. Task observation respects its requested/admitted wait and distinguishes stopping observation from stopping execution. Errors retain their concrete cause and supporting context.
No configuration or persisted format migration. Current tool authority still changes immediately when the authorized contract changes.
Architecture and complexity delta
Verification
The three CLI CI failures are corrected in test fixtures: declare cancellation with ErrorKind::Cancelled, assert the typed observation timeout, and register the held-child wait before releasing its semaphore. All three affected tests pass normally and under unsuppressed ThreadSanitizer. Production behavior and the 2-second observation budget are unchanged. Hosted CI on the updated head is pending.
Final checklist