Skip to content

bug: /handoff command step ordering and template structure lost under context compression #50

Description

@jflowers

Summary

internal/agentkit/content/command/handoff.md defines a 5-step session teardown workflow where ordering matters: summarize before release, release before sync, sync before session end. Under DCP context compression, the ordering gets flattened and the handoff note template structure gets dropped, producing unreliable session transitions.

Related to unbound-force/unbound-force#346 — same class of vulnerability (prompt constraints that do not survive context compression).

Specific Fragilities

1. Step ordering matters but is not reinforced

1. Summarize completed work and open blockers
2. comms_release_all() — free all file reservations
3. org_update() / org_close() — update cell statuses
4. org_sync() — persist state to git
5. org_session_end(handoff_notes="...") — save handoff for next session

If compression reorders or merges steps, an agent might:

  • Call comms_release_all() before summarizing (losing awareness of what was reserved)
  • Call org_sync() before org_close() (persisting stale state)
  • Call comms_release_all() while workers are still active in a concurrent forge session (no guard against this)

2. Handoff Note Template structure dropped (lines 19-25)

- Completed: What tasks were finished
- In Progress: What was started but not finished
- Blocked: What is waiting on external input
- Next Steps: What the next agent should do first
- Gotchas: Any surprises or edge cases discovered

This template is exactly the kind of structured content that compression drops to "write handoff notes." The resulting notes would be unstructured free-text, losing critical information categories (especially "Blocked" and "Gotchas") that the next session depends on.

3. No precondition check

The command does not instruct the agent to verify that no active forge workers are running before calling comms_release_all(). This is safe when the instruction is fresh, but after compression, an agent might invoke /handoff mid-forge and release active worker reservations.

Proposed Hardening

  • Add explicit ordering language: "Steps MUST execute in order — do not reorder or parallelize"
  • Embed the template structure in the org_session_end call itself rather than as a separate section: force the agent to construct structured notes as part of the workflow step
  • Add a precondition: "Before starting handoff, verify no forge workers are active via forge_status"

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions