mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-21 12:13:25 +00:00
fix(core): default unknown model token limits (#43541)
Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
This commit is contained in:
parent
30db9dd86e
commit
c85b09de6f
4 changed files with 20 additions and 5 deletions
|
|
@ -77,7 +77,7 @@ describe("ConfigProviderPlugin.Plugin", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("defaults custom models to agent capabilities", () =>
|
||||
it.effect("defaults custom model metadata", () =>
|
||||
Effect.gen(function* () {
|
||||
const catalog = yield* Catalog.Service
|
||||
const providerID = Provider.ID.make("custom")
|
||||
|
|
@ -100,6 +100,7 @@ describe("ConfigProviderPlugin.Plugin", () => {
|
|||
|
||||
const model = required(yield* catalog.model.get(providerID, modelID))
|
||||
expect(model.capabilities).toEqual({ tools: true, input: ["text", "image"], output: ["text"] })
|
||||
expect(model.limit).toEqual({ context: 200_000, output: 32_000 })
|
||||
}),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ export const Info = Schema.Struct({
|
|||
cost: [],
|
||||
status: "active",
|
||||
enabled: true,
|
||||
limit: { context: 0, output: 0 },
|
||||
limit: { context: 200_000, output: 32_000 },
|
||||
}) satisfies Info,
|
||||
})),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { describe, expect, test } from "bun:test"
|
||||
import { Schema } from "effect"
|
||||
import { Model } from "../src/model.js"
|
||||
import { Provider } from "../src/provider.js"
|
||||
|
||||
describe("Model.Ref", () => {
|
||||
test("parses model references with optional variants", () => {
|
||||
|
|
@ -49,3 +50,11 @@ describe("Model.Compatibility", () => {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("Model.Info", () => {
|
||||
test("uses practical token limits for unknown models", () => {
|
||||
const model = Model.Info.default(Provider.ID.make("custom"), Model.ID.make("gpt-5.6"))
|
||||
|
||||
expect(model.limit).toEqual({ context: 200_000, output: 32_000 })
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -85,9 +85,14 @@ You can also map a friendly catalog ID to a different API model ID with `modelID
|
|||
```
|
||||
|
||||
Here `openai/coding-default` is the selectable catalog reference, while `gpt-5.2` is sent to the provider. A model that is
|
||||
not already in the catalog defaults to tool support, text and image input, and text output. Set accurate `capabilities`
|
||||
and `limit` values when those defaults do not match the model or OpenCode needs to enforce its context limits. Set
|
||||
`disabled: true` on a model entry to hide it from the available catalog.
|
||||
not already in the catalog receives fallback metadata:
|
||||
|
||||
- Tool support, text and image input, and text output.
|
||||
- A 200,000-token context limit and 32,000-token output limit. The input limit remains unspecified.
|
||||
|
||||
These values are assumptions, not model discovery. Configure accurate `capabilities` and `limit` values whenever they are
|
||||
known; explicit values override the fallbacks. Set `disabled: true` on a model entry to hide it from the available
|
||||
catalog.
|
||||
|
||||
OpenAI-compatible models that stream reasoning through a custom assistant-message field can set
|
||||
`compatibility.reasoningField`:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue