Skip to content

fix: fusion report reliability, compaction boundaries and the branch's clippy blockers - #1694

Merged
jiangzhuqing000 merged 9 commits into
mainfrom
pr/dev-jiangzhuqing000
Nov 25, 2026
Merged

jiangzhuqing000 merged 9 commits into
mainfrom
pr/dev-jiangzhuqing000

Conversation

@jiangzhuqing000

Copy link
Copy Markdown
Collaborator

Opened manually: the dev 分支 PR 合并 scheduled task is not installed on the machine this branch was pushed from. Auto-merge is armed; the frozen head is origin/dev-jiangzhuqing000.

fusion: a report stage no longer replays its own thinking

A fusion step is one agent session, so the journal keeps the reasoning of every turn and a thinking-format API received that reasoning on the history each later request carried. On 2026-11-25 a moderator spent 130 KB of its 32,768-token output budget thinking, and the continuation plus repair requests replayed it until a 262,144-byte window had no room left: Fusion context has no generation space; request was not sent failed the step as an unattributed error, degrading the run to analysis_only.

without_replayed_reasoning now trims the wire copy to what the protocol requires — a turn that called a tool keeps its reasoning, every other turn loses it. The journal is untouched, and the budget now measures what is really sent.

A turn that still has no room to answer finishes the reply instead of failing the step, so the Host validates, repairs or degrades honestly.

agent: a recovered tool placeholder is not a checkpoint boundary

The placeholder exists only in memory and its ID is invented, so the compactor no longer treats that ID as a journal range boundary; it names the entry that issued the call instead.

lint: the clippy failures that kept make lint-rust red

  • packages/fd: gate MAX_PROBED_FDS with the #[cfg(unix)] of its only reader (Windows reported it as dead code).
  • agent/src/sandbox: as_chunks::<2>() in the UTF-16LE wrapper test.
  • agent/src/fusion: ContextScope::Parent is a couple of hundred bytes larger than Inner; the value lives in a task-local for one run, so boxing it would add an indirection through every construction site for no gain. Allowed with that reason.

Verification

  • cargo test -p future-agent --lib: 3124 passed (full crate suite on the fusion change).
  • cargo clippy --no-deps -p future-agent -p future-fd --all-targets -- -D warnings, cargo fmt --check, docs bilingual check: pass.
  • cargo test -p future-fd, and the Windows encoded-command sandbox test: pass.

Recovery invents an in-memory message for a tool call whose result never
reached the journal, and its ID (`missing-tool:<entry>:<call>`) is not a
journal identity. The compaction planner took message IDs as its range
boundary, so a plan whose range ended on such a placeholder asked the journal
to commit a checkpoint against an entry that does not exist. `receipt_entry`
refused it with "cached compaction checkpoint range is invalid", the run was
refused with persistence degraded, and every retry on that session failed the
same way: the session could never compact again.

Give recovery messages the journal entry that owns them
(`JOURNAL_BOUNDARY_ID_KEY`) and make compaction boundaries come from that
identity instead of the message's own. The projection also resolves a cutoff to
the last message sharing it, so an interrupted call and its placeholder are
summarized together and the retained tail never starts with an orphan tool
result. The refusal now logs the checkpoint entry, cutoff, covered-from and the
resolved positions, so a rejected range is diagnosable from the log alone.

Reproduced against a copy of a real 318k-token session before the fix (same
failure, run refused) and after it (checkpoint committed, run continued).
A fusion step is one agent session, so the journal keeps the reasoning of
every turn it produced and a thinking-format API gets that reasoning
replayed on the history each later request carries. A moderator that spent
130 KB of its 32,768-token output budget thinking therefore paid for the
same thinking twice — once when producing it, again on the continuation
and repair requests — until a 262,144-byte window had no room left and the
step died as an unattributed "no generation space" failure (2026-11-25).

Trim the wire copy of history to what the protocol requires: a turn that
called a tool keeps its reasoning, since a thinking-format API refuses
that round trip with HTTP 400; every other turn loses it. The journal is
untouched, so the transcript keeps the thinking and the budget now
measures what is really sent.

When a turn still has no room to answer, finish the reply instead of
failing the step: the visible text produced so far is a report the Host
can validate, repair or degrade honestly.

Tests: a report stage drops its own thinking and regains the full output
budget, a tool-call turn keeps it, and a request with no generation space
finishes cleanly without ever reaching the provider.
`make lint-rust` — the clippy step CI runs — was red on this branch for
three reasons, none of them from the fusion work:

- `packages/fd`: `MAX_PROBED_FDS` is only read by the `#[cfg(unix)]`
  probe, so a Windows build reported it as dead code. Gate the constant
  with the same cfg as its only reader.
- `agent/src/sandbox`: clippy wants `as_chunks::<2>()` instead of
  `chunks_exact(2)` in the UTF-16LE wrapper test.
- `agent/src/fusion`: `ContextScope::Parent` is a couple of hundred bytes
  larger than `Inner`. The value lives in a task-local for a single run,
  so boxing it would add an indirection through every construction and
  match site for no measurable gain; allow the lint with that reason.

No behaviour change.
@jiangzhuqing000
jiangzhuqing000 enabled auto-merge (squash) November 25, 2026 12:01
@jiangzhuqing000
jiangzhuqing000 merged commit ac899e1 into main Nov 25, 2026
29 checks passed
@jiangzhuqing000
jiangzhuqing000 deleted the pr/dev-jiangzhuqing000 branch November 25, 2026 12:27
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