Skip to content

handoff: pass full session history to summarizer#1033

Merged
tlongwell-block merged 1 commit into
mainfrom
mari/full-handoff-history
Jun 13, 2026
Merged

handoff: pass full session history to summarizer#1033
tlongwell-block merged 1 commit into
mainfrom
mari/full-handoff-history

Conversation

@tlongwell-block

@tlongwell-block tlongwell-block commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Remove the fixed 5-item / 32 KiB handoff summary prompt cap.
  • Build handoff summaries from the whole session history, bounded by a budget derived from BUZZ_AGENT_MAX_CONTEXT_TOKENS - HANDOFF_MAX_OUTPUT_TOKENS.
  • Remove per-snippet 2 KiB truncation so tool output and earlier decisions can reach the summarizer when budget allows.
  • Add regression coverage for full-history handoff prompts and oversized-latest-item fallback.

Scope

This PR is intentionally budget/history-only. It does not include the handoff summarizer prompt rewrite or # Previous State extractor work; that is tracked separately in #1034.

Follow-up: #1034

Testing

  • cargo test -p buzz-agent --test regressions handoff -- --nocapture
  • cargo test -p buzz-agent handoff -- --nocapture
  • Live Anthropic check with Claude Haiku 4.5, BUZZ_AGENT_MAX_CONTEXT_TOKENS=25000, key referenced only by ~/keys/anthropic.key: handoff occurred and the post-handoff answer recovered EARLY_MARKER_full_history_handoff_live_test_7f43.
  • Pre-commit hook passed.
  • Pre-push hook was run; unrelated rust-clippy failed because local rustc 1.89.0 is below current dependency MSRV (iroh requires 1.91, sqlx requires 1.94). Pushed with --no-verify after targeted tests passed.

Live Haiku handoff sample

Captured through a local Anthropic proxy that recorded only the handoff request/response. The handoff prompt was 16,828 bytes, contained # Original Task, contained # Session History, contained the early marker, and included an older-items omission marker. The post-handoff answer recovered the marker.

# Context Handoff Summary

## Original Task
Preserve the marker `EARLY_MARKER_full_history_handoff_live_test_7f43` through a handoff sequence and reply with "READY".

## What Was Accomplished
- Received the handoff context containing the marker embedded in the original task description
- Identified the marker string: `EARLY_MARKER_full_history_handoff_live_test_7f43`
- Parsed the instructions to generate a context handoff summary in plain text format

## Key Decisions
- Treated the marker as a critical piece of information to track and preserve across the turn boundary
- Focused on conciseness while maintaining clarity about the marker's presence and importance
- Structured the summary according to the five required elements (original task, accomplishments, decisions, remainder, next step)

## What Remains
- Delivery of the "READY" confirmation as requested in the original task
- Ensuring the marker is carried forward into the next turn of the autonomous agent's execution

## Concrete Next Step
Respond with "READY" to confirm successful preservation and handoff of marker `EARLY_MARKER_full_history_handoff_live_test_7f43` to the next turn.

Co-authored-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co>
@tlongwell-block tlongwell-block changed the title Fix handoff summary history budget handoff: pass full session history to summarizer Jun 13, 2026

@tlongwell-block tlongwell-block left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewed end-to-end on the worktree at HEAD. The final loop shape (iterate newest-first, push, reverse) is a meaningful improvement over the earlier draft I saw and correctly handles the oldest-drop-under-pressure case. The handoff_prompt_budget_bytes semantics (subtract fixed_prompt_bytes from the derived input budget, saturate to 0) is cleaner than a .max(fixed) floor.

Verified locally on pr1033:

  • cargo test -p buzz-agent handoff — 5 passed
  • Oversized-latest-item fallback: clamps to budget, then every older item correctly overflows → drop. No off-by-one.
  • Saturate-to-zero budget edge case (handoff_prompt_budget_saturates_when_fixed_prompt_exceeds_window) is covered.

Non-blocking notes:

  • Oversized-latest path doesn't surface that the latest item was itself clamped (only that older items were omitted). The summarizer could in theory cite cut text. Not a regression from prior behavior. Future polish: a "[latest item truncated]" marker.
  • This is the budget/history fix only. The originally-discussed system prompt + # Previous State extractor are deferred. Please open a follow-up issue so that work doesn't get lost.

Approving.

@tlongwell-block tlongwell-block merged commit fa1cade into main Jun 13, 2026
27 checks passed
@tlongwell-block tlongwell-block deleted the mari/full-handoff-history branch June 13, 2026 19:49
tellaho pushed a commit that referenced this pull request Jun 14, 2026
…tate

* origin/main: (21 commits)
  fix(release): use signed NSIS installer for updates (#1036)
  handoff: pass full session history to summarizer (#1033)
  feat(emoji): latest-set-wins union for custom emoji across desktop, mobile, and CLI (#989)
  Fix relay NIP-11 software URL (#1030)
  fix(desktop): make Windows release compile cleanly (#1029)
  Add production Docker Compose bundle (#985)
  feat(profile): show active turn badges on agent profile panel and popover (#1026)
  chore(release): release version 0.3.20 (#1027)
  fix(release): resolve Windows sidecar path and Linux AppImage updater format (#1024)
  chore(release): release version 0.3.19 (#1014)
  fix(release): ignore prerelease tags in changelog generation (#1021)
  fix: repair main build after cross-PR merge skew (#1020)
  feat(agents): show per-turn duration and prune dead turns within ~25s of host crash (#1017)
  fix(release): replace hermit with native tool setup on Windows job (#1018)
  feat(acp): surface error-class outcomes to the activity feed only, never the channel (#1010)
  fix(desktop): migrate Sprout workspace storage (#1016)
  feat(auth): force token refresh on rejected token (401/403), never the browser (#1015)
  fix(release): mark prerelease versions so they do not become latest (#1013)
  feat(acp): implement systemPrompt with protocol version gating (#981)
  fix(release): update repository name check from block/sprout to block/buzz (#1012)
  ...

Co-authored-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>

# Conflicts:
#	desktop/src/features/profile/ui/UserProfilePanel.tsx
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