pi-mono/packages/coding-agent/src
robopipi[bot] d0fe213089
fix(coding-agent): apply context edits to branch summary input (#11680)
When a partial assistant reply fails and automatic retry succeeds, pi
appends a `context_edit` that hides the failed attempt from model
context. Branch summarization (`/tree` with summarize) built its input
from raw session entries through `getMessageFromEntry`, which ignored
`context_edit` entries. As a result, the summarizer received the hidden
attempt again. Content replacements were ignored the same way.

What the change does:
- `prepareBranchEntries` now collects the latest `context_edit` for each
target in the branch.
- It applies those edits to the entries it converts, using the same
`projectContextEntry` logic as the live context and compaction:
  - an omission (`replacement: null`) drops the entry;
  - a replacement swaps its content.
- `projectContextEntry` is now exported from `session-manager.ts` so
both paths share it.
- The existing branch-summary behavior is unchanged: tool results are
still skipped, and compaction or branch-summary entries still become
summary messages.

Testing:
- Added `applies context edits to branch entries` to
`test/branch-summarization.test.ts`. It covers one omitted assistant
entry and one replaced assistant entry. The test fails without the
change and passes with it.
- Ran `branch-summarization`, `branch-summary-extensions`,
`agent-session-branching` and the compaction tests: all pass.
- `npm run check`: biome and the coding-agent checks pass. `tsc` reports
6 errors in `packages/ai` model-catalog tests, and the same 6 errors
occur on unmodified `main`.
- End-to-end reproduction with the faux provider and `AgentSession`: a
failed attempt, a successful retry, then `navigateTree(target, {
summarize: true })`. Before the change, the summary request contained
the failed attempt's text. After the change, it contains only the
successful retry.

Fixes #11602

Requested by @davidbrai

Co-authored-by: triagent <triagent@localhost>
2026-11-02 10:55:30 +01:00
..
bun feat(coding-agent): codemode and MCP 2026-09-29 09:12:50 +02:00
cli feat(coding-agent): add PI_SELF_UPDATE_COMMAND and selfUpdateCommand for pi update (#11629) 2026-10-30 22:30:39 +01:00
core fix(coding-agent): apply context edits to branch summary input (#11680) 2026-11-02 10:55:30 +01:00
experimental feat(coding-agent): remove the experimental server stack and the client, protocol, and server packages 2026-10-12 10:41:59 +00:00
extensions fix(coding-agent,tui): reuse syntax highlighting and rendered Markdown blocks 2026-11-01 14:40:56 +01:00
modes fix(coding-agent,tui): reuse syntax highlighting and rendered Markdown blocks 2026-11-01 14:40:56 +01:00
utils fix(coding-agent,tui): reuse syntax highlighting and rendered Markdown blocks 2026-11-01 14:40:56 +01:00
cli.ts fix(coding-agent): keep remote harness dependencies development-only 2026-09-05 12:45:04 +02:00
config.ts feat(coding-agent): add PI_SELF_UPDATE_COMMAND and selfUpdateCommand for pi update (#11629) 2026-10-30 22:30:39 +01:00
index.ts fix(coding-agent): pass host keybinding hints to extension renderers (#11630) 2026-10-30 23:01:20 +01:00
main.ts fix(coding-agent): honor saved project trust for projects without trust-requiring resources 2026-10-29 21:10:03 +01:00
migrations.ts fix(coding-agent): update repository links to "earendil-works/pi" (#9278) 2026-09-07 14:09:39 +02:00
package-manager-cli.ts feat(coding-agent): add PI_SELF_UPDATE_COMMAND and selfUpdateCommand for pi update (#11629) 2026-10-30 22:30:39 +01:00
rpc-entry.ts feat(coding-agent): set AI_AGENT environment variable (#7493) 2026-08-03 13:45:32 +02:00