mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
feat(coding-agent): Virtual models (#10035)
This adds experimental support for virtual models. A virtual model is a catalog entry that an extension registers with pi.registerVirtualModel(). It does not talk to a provider itself; for every request it picks a physical model and thinking level. The motivation is to make routing policies pluggable: plan on a strong model and implement on a cheap one, pick a model with a classifier, or move to a larger window when the context grows. Today this needs model switching by hand or hacks in prepareRequest. The selection stays virtual: model_change records it, resume restores it, and each response records the physical model and thinking level that produced it. Router state can be stored on the session branch, so it follows /tree and forks and survives compaction. Context limits, compaction and image sizing use the physical model a request was routed to. examples/extensions/jev-router.ts shows a full router that uses the Jev classifier to pick Sol or Terra for planning and hands off to Luna after the first edit. docs/virtual-models.md describes the API.
This commit is contained in:
parent
1b2aa0ca0e
commit
540e174c72
26 changed files with 1877 additions and 116 deletions
|
|
@ -404,6 +404,8 @@ async function streamAssistantResponse(
|
|||
apiKey: resolvedApiKey,
|
||||
signal,
|
||||
});
|
||||
// Record the requested level, whichever stream function answered.
|
||||
const result = async () => Object.assign(await response.result(), { thinkingLevel: config.reasoning ?? "off" });
|
||||
|
||||
let partialMessage: AssistantMessage | null = null;
|
||||
let addedPartial = false;
|
||||
|
|
@ -439,7 +441,7 @@ async function streamAssistantResponse(
|
|||
|
||||
case "done":
|
||||
case "error": {
|
||||
const finalMessage = await response.result();
|
||||
const finalMessage = await result();
|
||||
if (addedPartial) {
|
||||
context.messages[context.messages.length - 1] = finalMessage;
|
||||
} else {
|
||||
|
|
@ -454,7 +456,7 @@ async function streamAssistantResponse(
|
|||
}
|
||||
}
|
||||
|
||||
const finalMessage = await response.result();
|
||||
const finalMessage = await result();
|
||||
if (addedPartial) {
|
||||
context.messages[context.messages.length - 1] = finalMessage;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue