feat(coding-agent): add prompt cache warming (#9668)

This commit is contained in:
Armin Ronacher 2026-09-19 21:18:15 +02:00 • committed by GitHub
parent 7d5eb0ee3b
commit c596d09d9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 1380 additions and 69 deletions

View file

@ -738,6 +738,25 @@ pi.on("after_provider_response", (event, ctx) => {
Header availability depends on provider and transport. Providers that abstract HTTP responses may not expose headers.
#### cache_warming_decision
Fired before each prompt-cache refresh with pi's decision filled in. The event carries only pi's cost estimates; use `ctx.model`, `ctx.isIdle()`, and `ctx.getContextUsage()` for everything else.
```typescript
pi.on("cache_warming_decision", (event, ctx) => {
// event.warmCost: price of this refresh
// event.missCost: extra price of the next request if the entry is lost
// event.continuationProbability: pi's estimate that a request arrives in time
// event.action: "warm" | "stop", pi's decision
if (ctx.model?.provider === "my-provider") {
return { action: "stop" };
}
});
```
Return `{ action: "warm" }` or `{ action: "stop" }` to override; the last handler that returns an action wins. `"stop"` ends warming until the next real request.
### Model Events
#### model_select