mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
feat(coding-agent): add prompt cache warming (#9668)
This commit is contained in:
parent
7d5eb0ee3b
commit
c596d09d9c
32 changed files with 1380 additions and 69 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue