d3fc6f2bfada18e6ae7887b79ed1e4c650ca37e1
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6bc5702cd4 |
agent: magpie's OpenCode provider sets setCacheKey, so OpenCode sends its session's prompt_cache_key (#5468)
mariamatrix (#5468) and mahiro233 on Discord: magpie writes OpenCode's magpie provider with @ai-sdk/openai-compatible and only baseURL/apiKey, so OpenCode sends no prompt_cache_key and an upstream that caches by it misses. Checked against OpenCode's source and real runs (sandbox HOME on mote, a recording Chat server): - 2.2.5: v1/config/migrate.ts maps options.setCacheKey to compatibility.supportsPromptCacheKey, and openai-chat.ts sends prompt_cache_key only then. Without it: no key; with it: "prompt_cache_key":"ses_…" on the turn and the title request. A config with magpie's provider under providers, compatibility.supportsPromptCacheKey true, sends it too; without, none. - 1.19.5: setCacheKey true sends camelCase promptCacheKey (the previous commit sends it on as prompt_cache_key). - 2.0.25: ignores the option; the run answers as before, no error. Now: - the "opencode" shape's options have setCacheKey: true. Every writer of provider.magpie goes through it and openCodeKept: OpenCode, its OPENCODE_CONFIG_DIR copies, MiMo Code, DevEco, Air's OpenCode and OpenChamber's. - openCodeNative writes it as OpenCode 2 does: compatibility .supportsPromptCacheKey, not a setting. - a setCacheKey the file has already under provider.magpie.options, or a supportsPromptCacheKey under providers.magpie.compatibility, is the user's (false too) and stays, through a sync and a pick. Kilo has no wiring in magpie; no other agent's config has this option. TestAirProviderWritesKeepCustomFields compared every option as a string; it now compares a bool as its JSON. Run on mote: go test ./internal/agent (full package) ok; go test -run 'OpenCode|CacheKey|Air|OpenChamber|Deveco|Mimo|KeepTheir' ./internal/agent ./internal/gateway ok; go vet on darwin, GOOS=linux, GOOS=windows; go build ./... (darwin, windows); gofmt clean. Broken by hand, each failing TestOpenCodeSetsCacheKey: no setCacheKey in the shape ("no setCacheKey"); no keep under provider ("the user's false not kept"); no keep under providers (same); no move out of settings ("setCacheKey in OpenCode 2's settings"). Not tried: a config written by a running magpie fed to a real OpenCode (the real runs used configs of the same shape, written by hand); a real upstream's cache hit rate before and after. Reported-by: mariamatrix Reported-by: mahiro233 |
||
|
|
0ed9891de0 |
agent: magpie's provider under OpenCode 2's providers is kept current (#3883)
Murciee (#3883, OpenCode 2.1.4 as OpenChamber bundles it, Windows): a model added in magpie never reached OpenCode 2, though magpie said it was exposed. ~/.config/opencode/opencode.json held magpie's provider twice, provider.magpie with 43 models and providers.magpie with 38, and opencode models listed the 38. OpenCode 2 keeps a provider under providers, in words of its own, and still reads OpenCode 1's provider: a provider named under both is the one under providers, whole, and the other only a WARN in its log, "retained native value over legacy value" (packages/core/src/config/normalize.ts, mergeMaps, at v2.1.4). OpenChamber's provider form saves a provider under providers and takes it out of provider (packages/web/server/lib/opencode/config-v2.js, writeSectionEntry). Once it had saved magpie's, magpie's next sync put provider.magpie back, as a model of magpie's was picked, and from then on brought only that one up to date. Where an OpenCode config keeps magpie's provider under providers, each sync and model pick now write it there too, and the wiring check reads it there (opencode_providers.go). It is written as OpenCode 2 reads magpie's provider.magpie (packages/core/src/v1/config/migrate.ts, migrateStandardProvider and migrateModel): npm as package "aisdk:<npm>", options as settings, a model's modalities as capabilities beside tools, its variants a list of {id, settings, body} with the options OpenCode 2 reads itself in settings and the rest in body (provider-options.ts, COMPATIBLE_KEYS: a fast variant's service_tier), and reasoning, which it doesn't read, left out. As under provider (theirsKept, openCodeKept), magpie's models are written whole, a key of the user's in the block stays, and so does a variant the user put on a model of magpie's. A variant is magpie's when it says what magpie's of its name says, split as OpenCode 2 splits it or all in settings, as OpenChamber carries one over from provider (toModelVariants). A config without providers.magpie doesn't get one: provider.magpie is still what magpie writes, and OpenCode 1 and 2 both read it. Taking magpie out of OpenCode or OpenChamber takes out both blocks, as OpenChamber's own delete does. agent-wiring.md says so beside #2379's variants. Old data: a config already in the reporter's state is brought up to date by the next sync, which SyncCatalog runs over every agent at each start and update of magpie. A providers.magpie an older magpie left behind when taking magpie out (it took out provider.magpie alone) is kept up to date from now on, and goes the next time magpie is taken out. Not changed: - Air: its magpie-opencode.json is magpie's own and holds provider.magpie alone. With OpenChamber's providers.magpie in the global config and nothing else of magpie's there, OpenCode 2.1.4 handed Air's file as OPENCODE_CONFIG still listed the model only Air's file had. - MiMo Code and DevEco Code go through the same code. Their configs hold no providers block unless something of theirs writes one; not checked against their source. - A provider of the user's own at magpie's gateway kept under providers isn't read by openCodeSpelled and ownGatewayProvider, which read provider alone: #3915, filed with this. - What else OpenChamber's form puts on a model of magpie's under providers (a modelID, a cost) goes with the rest of the model at the next sync, as a key on one under provider does today. What was run (tree 61b3fff7, on origin/main |