fix(coding-agent): restore extension input source semantics
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1299,7 +1299,7 @@ export class AgentSession {
|
||||
expandPromptTemplates: false,
|
||||
streamingBehavior: options?.deliverAs,
|
||||
images,
|
||||
source: "interactive",
|
||||
source: "extension",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user