Skip to content

fix(agent): keep context maintenance working after unknown results - #6539

Merged
M4n5ter merged 1 commit into
rust-previewfrom
fix/context-maintenance-after-unknown
Nov 1, 2026
Merged

M4n5ter merged 1 commit into
rust-previewfrom
fix/context-maintenance-after-unknown

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Nov 1, 2026

Copy link
Copy Markdown
Member

Summary

A tool dispatched before an interrupted run could remain unknown in durable history. That historical state permanently disabled automatic compaction and result pruning, allowing later requests to grow beyond the configured context window.

Unify history admission so failed or cancelled historical operations can participate in context maintenance, including after reopening the database and reading frozen or lineage context. The summarizer receives ordinary history with unknown tool results and decides what belongs in its summary. Remove the separately pinned operation list, system warning, and the check that refused progress without that list. Existing affected sessions need no manual database repair.

Restore output tokens per second in the context usage tooltip, using the existing localized metric and preserving zero as a valid reading.

Context usage tooltip showing output speed

Verification

  • Event-log integration suite: 141 passed; reran all 14 context-compaction cases after the final changes.
  • Engine integration: 24 related cases passed, covering automatic compaction, overflow recovery, interruptions, pruning, and handoff. The new HTTP-level regression verifies that historical uncertainty reaches the summarizer, its summary is adopted, old operations are not pinned back into subsequent requests, and the task completes without replaying old tools.
  • Real UI checks passed for output-speed updates, including zero, and the native desktop tooltip shown above.
  • Clippy for maka-event-log and maka-agent-engine, including all targets and features, passed with warnings denied. Rust formatting, affected UI TypeScript checking, Biome, and diff checks passed.
  • Removed the obsolete assertion that required historical unknown effects to block continuation; retained the lineage and frozen-retry behavior checks.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex implemented and reviewed the changes and ran the verification.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Treat failed or cancelled historical tool effects as model context rather than a permanent barrier to compaction, pruning, and subsequent work. Remove the duplicate persistent warning and let the summarizer decide what to retain.

Restore output tokens per second in the context usage tooltip.

Generated-by: Codex
@M4n5ter
M4n5ter merged commit 0097ac6 into rust-preview Nov 1, 2026
6 checks passed
@M4n5ter
M4n5ter deleted the fix/context-maintenance-after-unknown branch November 1, 2026 13:09

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

I reviewed all 26 changed files at 69f4fb30e5bd3a941b378740f46b54b633e92a8e, including the indexed/historical safety queries, frozen/lineage context, compaction/pruning admission, provider request composition and output-speed presentation.

P2 — The existing native regression still requires the system warning this patch removes. plugins/agent/native/src/owner/tests/todo_tests.rs:169 asserts that a system message contains both todo_write and may or may not have happened. This patch removes prior_unknown_notice and its system-message injection, but only renames the history-check call later in that same test. Consequently PR CI 41309796265 fails at that assertion: its third worker reports 499 passes and one failure. The failure persists in the later Mermaid PR run and Rust merge run. Update the obsolete system-message assertion to the intended contract while preserving checks for the outcome_unknown tool message, the new user message and absence of replayed effects. The actual failed-request log still contains that unknown tool result; this finding is a CI regression, not evidence that the result disappeared.

For the production changes, context/safety.rs:69 continues to reject live unresolved work, while closed failed/cancelled uncertainty becomes context; the historical queries retain their sequence fences. runner.rs, steps.rs and compact.rs remove the permanent compaction/pruning exemption and carry the source uncertainty marker into summary capture. The deleted duplicate system warning and pinned operation list are intentional parts of the change. I did not find another confirmed P0–P2 defect in this source review.

I ran 17 controlled SQLite checks using the actual extracted production query strings, covering indexed obligations, failed/cancelled provider effects, foreign/current-session boundaries and older cuts that cannot borrow later closure or settlement. These use small fixture tables, not the Rust EventLog or a user's database. Three checks of the actual contextUsageText function also passed for 100.5, zero and absent speed; the conversation adapter normalizes missing metrics to null.

I did not execute Rust, the HTTP/model compaction regression, durable reopen/lineage recovery, database upgrade, real side effects or native tooltip rendering locally. The broader engine/event-log/native results in the PR description remain the author's results. The CI failure above must not be hidden by those focused results.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

// Root recovery runs only after every physical worker has stopped.
f.store.recover_invocations().await.unwrap();
assert!(f.session(&session).await.check_manual_message_history(&session).await.unwrap());
assert!(f.session(&session).await.check_history(&session).await.unwrap());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] This renames the admission call but leaves the assertion at line 169 in the same test unchanged. That assertion still requires the duplicate system warning removed from model_attempt.rs / request_composition.rs, so CI 41309796265 fails here with 499 passes and one failure in its third worker. Check the intended outcome_unknown tool result and no-replay behavior without requiring the removed system warning.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

M4n5ter added a commit that referenced this pull request Nov 2, 2026
The duplicate historical system notice was intentionally removed in #6539. Assert that the original counter-call tool response retains outcome_unknown and its inspect-before-repeating warning instead. Reuse the same checks after the second restart and retain the durable effect and single-dispatch assertions.

Generated-by: Maka
liugddx added a commit that referenced this pull request Nov 2, 2026
…r sends (#6548)

#6539 removed the duplicate persistent warning after an unknown tool result and
leaves the unknown outcome to the tool result itself, but this test still
required the removed system message. rust-preview CI has failed on it since.
The assertion that the tool result says outcome_unknown stays.

Co-authored-by: Claude Opus 5.5 <[email protected]>
liugddx added a commit that referenced this pull request Nov 2, 2026
* feat(agent): wake the Bot when a worker it created finishes a run

The Bot keeps a durable watch for each conversation it creates or sends to. A
background pass reports every finished run of a watched worker to the Bot once,
as a new origin-tagged message through the existing notification admission, so
a Bot that went to sleep after delegating is woken by the result. The message
is a pointer, not the result: it tells the Bot to read the worker's actual
outcome before telling the user.

A busy Bot keeps the report pending until it is idle. The report identity comes
from the worker and invocation, so a retry or restart never repeats it. Pauses
and context compactions are not results. Archived or foreign watches are
dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(agent): run a Bot's workers on the Bot's own model

A model selection carries the connection's revision, which the Bot has no way
to know, so every SessionSend from a real Bot was refused as an unavailable
model and surfaced only as an unconfirmed result. A worker now runs on the
model the Bot itself is running on, resolved against the current connection
revision; the selection the Bot supplies is replaced. The Bot's instructions
say so.

The delegation test now serves the wake Turn the finished worker causes, which
otherwise raced with its idle check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(workbench): keep Host-written messages out of the Bot's Chat

A worker finishing wakes the Bot with a message the Host wrote, but Chat showed
it as a bubble the user had apparently typed, with copy and edit controls and
an internal instruction in it. History rows now keep the message origin; the
Bot's Chat hides origin-tagged user messages, and Trajectory shows them so the
wake stays inspectable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* style(agent): format MessageOrigin the way CI's rustfmt does

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(workbench): let process rows carry the message origin

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(agent): drop the unknown-outcome system note the engine no longer sends

#6539 removed the duplicate persistent warning after an unknown tool result and
leaves the unknown outcome to the tool result itself, but this test still
required the removed system message. rust-preview CI has failed on it since.
The assertion that the tool result says outcome_unknown stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants