fix(core): cap session output tokens

This commit is contained in:
Dax Raad 2026-07-10 23:45:37 +00:00 committed by opencode-agent[bot]
commit 0ca670e6dc
2 changed files with 26 additions and 0 deletions

View file

@ -108,6 +108,11 @@ const recoveryModel = Model.make({
provider: "fake",
route: OpenAIChat.route.with({ limits: { context: 20_000, output: 1_000 } }),
})
const fullContextOutputModel = Model.make({
id: "full-context-output",
provider: "fake",
route: OpenAIChat.route.with({ limits: { context: 500_000, output: 500_000 } }),
})
const authorizations: Tool.Context[] = []
const executions: string[] = []
const permission = Layer.succeed(
@ -655,6 +660,22 @@ describe("SessionRunnerLLM", () => {
}),
)
it.effect("caps output when the catalog output limit consumes the full context window", () =>
Effect.gen(function* () {
yield* setup
const session = yield* SessionV2.Service
currentModel = fullContextOutputModel
yield* session.prompt({ sessionID, prompt: Prompt.make({ text: "hi" }), resume: false })
requests.length = 0
response = []
yield* session.resume(sessionID)
expect(requests).toHaveLength(1)
expect(requests[0]?.generation).toEqual({ maxTokens: 32_000 })
}),
)
it.effect("retries the first provider turn after system context becomes available", () =>
Effect.gen(function* () {
yield* setup