Skip to content

session_compact custom message misses the immediate overflow retry #9051

Description

@n-r-w

What happened?

In @earendil-works/pi-coding-agent 0.84.4, a session_compact handler can restore provider-visible context with pi.sendMessage(..., { triggerTurn: false }). During overflow recovery, Pi queues that message until the retried turn ends. The immediate retry therefore runs without the restored context.

This affects extensions that republish exact state after compaction. The compaction summary is applied, but the first request after overflow recovery cannot see the state published by session_compact.

Example of an affected extension: https://github.com/n-r-w/pi-agent-suite/blob/main/docs/extensions/workflow.md#:~:text=After%20session_compact%2C%20the,guidelines%3D%22inline%22.

Steps to reproduce

Attached:

Send two prompts. The fake provider completes the first request, returns a deterministic overflow on the second request, and checks the context received by the automatic retry. The extension supplies a compaction result and publishes RESTORED_CONTEXT_MARKER from session_compact.

On 0.84.4, the retried request reports: BUG REPRODUCED: restored context was missing from the overflow retry.

Expected behavior

A passive custom message published by session_compact must be included in the immediate overflow retry. The reproducer should report: EXPECTED BEHAVIOR: restored context reached the overflow retry.

The message must remain after completed tool results and must not be inserted between an assistant tool call and its result.

Version

0.84.4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions