Skip to content

Fix post-compact handoff context for OpenAI providers#931

Merged
tlongwell-block merged 2 commits into
mainfrom
perci/fix-handoff-postcompact-context
Jun 10, 2026
Merged

Fix post-compact handoff context for OpenAI providers#931
tlongwell-block merged 2 commits into
mainfrom
perci/fix-handoff-postcompact-context

Conversation

@tlongwell-block

Copy link
Copy Markdown
Collaborator

Summary

  • Fold _PostCompact output into the synthetic handoff user context block instead of injecting it as a synthetic tool result after history reset
  • Preserve the hook output as explicitly untrusted context
  • Update the regression to assert the hook output remains visible and no orphan role: "tool" messages are sent after handoff

Why

During handoff, history is cleared before _PostCompact output is injected. Emitting that output as a tool result leaves OpenAI-compatible requests with an orphan role: "tool" message that has no preceding assistant tool call. That can invalidate or derail the post-handoff turn and looks like agents restarting from handoff instead of continuing cleanly.

Test plan

  • cargo test -p sprout-agent hook_post_compact_injects_after_handoff --test regressions
  • pre-commit passed: rust fmt, desktop Tauri fmt, mobile format/analyze, desktop/web biome + file-size checks
  • pre-push was bypassed after unrelated existing desktop Tauri test compile failure on current origin/main with unstable str::floor_char_boundary use in desktop/src-tauri/src/commands/agent_discovery.rs

@tlongwell-block tlongwell-block requested a review from a team as a code owner June 9, 2026 20:14
Signed-off-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co>
@tlongwell-block tlongwell-block force-pushed the perci/fix-handoff-postcompact-context branch from 996953f to 349b1b4 Compare June 9, 2026 20:14
Signed-off-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co>
@tlongwell-block tlongwell-block force-pushed the perci/fix-handoff-postcompact-context branch from 1ea03b9 to 92e2585 Compare June 10, 2026 01:35
@tlongwell-block tlongwell-block merged commit fe14daa into main Jun 10, 2026
16 checks passed
@tlongwell-block tlongwell-block deleted the perci/fix-handoff-postcompact-context branch June 10, 2026 01:56
tlongwell-block pushed a commit that referenced this pull request Jun 10, 2026
* origin/main:
  Fix post-compact handoff context for OpenAI providers (#931)
  chore(release): release version 0.3.15 (#936)
  fix: persona is source of truth at spawn + thread-depth conventions (#930)
  fix: skip avatar reconciliation for legacy agent records (#933)
  feat(desktop): add nest commit identity guidance with human sign-off (#929)
  feat: provider/model selection for personas and runtime-aware env injection (#794)
  fix: reconcile agent profile on startup when relay publish was missed (#921)
  Revamp first-run onboarding (#924)
  Update setup loading screen (#926)
  fix(dm): keep hidden DMs hidden across refetch via relay-signed visibility snapshot (NIP-DV) (#857)
  Maximize desktop window on launch (#925)
  feat: preview features (experiments settings UI) (#888)
  fix(updater): send no-cache header on update check to avoid stale manifest (#922)
  fix(desktop): refresh channel state after unarchive (#923)
  Add channel visibility & ephemeral TTL controls to manage sidebar (#911)
  ci(release): add Intel macOS (x86_64) DMG as a release target (#748)

Signed-off-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co>

# Conflicts:
#	desktop/src/features/sidebar/ui/AppSidebar.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