diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 7e0cbd78..84e6064f 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fixed extension-queued user messages to refresh the interactive pending-message list while preserving `input` event source semantics for `pi.sendUserMessage()` ([#2674](https://github.com/badlogic/pi-mono/pull/2674) by [@mrexodia](https://github.com/mrexodia)) + ## [0.63.2] - 2026-03-29 ### New Features diff --git a/packages/coding-agent/docs/json.md b/packages/coding-agent/docs/json.md index e1a68a85..fbbc3f73 100644 --- a/packages/coding-agent/docs/json.md +++ b/packages/coding-agent/docs/json.md @@ -13,12 +13,15 @@ Events are defined in [`AgentSessionEvent`](https://github.com/badlogic/pi-mono/ ```typescript type AgentSessionEvent = | AgentEvent - | { type: "auto_compaction_start"; reason: "threshold" | "overflow" } - | { type: "auto_compaction_end"; result: CompactionResult | undefined; aborted: boolean; willRetry: boolean; errorMessage?: string } + | { type: "queue_update"; steering: readonly string[]; followUp: readonly string[] } + | { type: "compaction_start"; reason: "manual" | "threshold" | "overflow" } + | { type: "compaction_end"; reason: "manual" | "threshold" | "overflow"; result: CompactionResult | undefined; aborted: boolean; willRetry: boolean; errorMessage?: string } | { type: "auto_retry_start"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string } | { type: "auto_retry_end"; success: boolean; attempt: number; finalError?: string }; ``` +`queue_update` emits the full pending steering and follow-up queues whenever they change. `compaction_start` and `compaction_end` cover both manual and automatic compaction. + Base events from [`AgentEvent`](https://github.com/badlogic/pi-mono/blob/main/packages/agent/src/types.ts#L179): ```typescript diff --git a/packages/coding-agent/docs/rpc.md b/packages/coding-agent/docs/rpc.md index 162ffd94..cb0a549a 100644 --- a/packages/coding-agent/docs/rpc.md +++ b/packages/coding-agent/docs/rpc.md @@ -725,8 +725,9 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO | `tool_execution_start` | Tool begins execution | | `tool_execution_update` | Tool execution progress (streaming output) | | `tool_execution_end` | Tool completes | -| `auto_compaction_start` | Auto-compaction begins | -| `auto_compaction_end` | Auto-compaction completes | +| `queue_update` | Pending steering/follow-up queue changed | +| `compaction_start` | Compaction begins | +| `compaction_end` | Compaction completes | | `auto_retry_start` | Auto-retry begins (after transient error) | | `auto_retry_end` | Auto-retry completes (success or final failure) | | `extension_error` | Extension threw an error | @@ -862,19 +863,32 @@ When complete: Use `toolCallId` to correlate events. The `partialResult` in `tool_execution_update` contains the accumulated output so far (not just the delta), allowing clients to simply replace their display on each update. -### auto_compaction_start / auto_compaction_end +### queue_update -Emitted when automatic compaction runs (when context is nearly full). - -```json -{"type": "auto_compaction_start", "reason": "threshold"} -``` - -The `reason` field is `"threshold"` (context getting large) or `"overflow"` (context exceeded limit). +Emitted whenever the pending steering or follow-up queue changes. ```json { - "type": "auto_compaction_end", + "type": "queue_update", + "steering": ["Focus on error handling"], + "followUp": ["After that, summarize the result"] +} +``` + +### compaction_start / compaction_end + +Emitted when compaction runs, whether manual or automatic. + +```json +{"type": "compaction_start", "reason": "threshold"} +``` + +The `reason` field is `"manual"`, `"threshold"`, or `"overflow"`. + +```json +{ + "type": "compaction_end", + "reason": "threshold", "result": { "summary": "Summary of conversation...", "firstKeptEntryId": "abc123", diff --git a/packages/coding-agent/docs/sdk.md b/packages/coding-agent/docs/sdk.md index dc5f93ca..6371cfec 100644 --- a/packages/coding-agent/docs/sdk.md +++ b/packages/coding-agent/docs/sdk.md @@ -232,9 +232,12 @@ session.subscribe((event) => { // event.toolResults: tool results from this turn break; - // Session events (auto-compaction, retry) - case "auto_compaction_start": - case "auto_compaction_end": + // Session events (queue, compaction, retry) + case "queue_update": + console.log(event.steering, event.followUp); + break; + case "compaction_start": + case "compaction_end": case "auto_retry_start": case "auto_retry_end": break; diff --git a/packages/coding-agent/src/core/agent-session.ts b/packages/coding-agent/src/core/agent-session.ts index 42124f41..d1400805 100644 --- a/packages/coding-agent/src/core/agent-session.ts +++ b/packages/coding-agent/src/core/agent-session.ts @@ -1299,7 +1299,7 @@ export class AgentSession { expandPromptTemplates: false, streamingBehavior: options?.deliverAs, images, - source: "interactive", + source: "extension", }); } diff --git a/packages/coding-agent/test/agent-session-concurrent.test.ts b/packages/coding-agent/test/agent-session-concurrent.test.ts index f3281e97..20aa17df 100644 --- a/packages/coding-agent/test/agent-session-concurrent.test.ts +++ b/packages/coding-agent/test/agent-session-concurrent.test.ts @@ -281,7 +281,7 @@ describe("AgentSession concurrent prompt guard", () => { expect(session.pendingMessageCount).toBe(1); expect(session.getSteeringMessages()).toContain("Steer from extension"); - expect(lastInputSource).toBe("interactive"); + expect(lastInputSource).toBe("extension"); expect(queueEvents.some((event) => event.steering.includes("Steer from extension"))).toBe(true); await session.abort();