| β¦ | β¦ | @@ -0,0 +1,33 @@ | |
| 21 | + | }): string | null => { | |
| 22 | + | if (input.causeTag !== "InvalidRequestError") return null; | |
| 23 | + | if (input.windowTokens === undefined || input.steps === 0) return null; | |
| 24 | + | if (input.inputTokens < input.windowTokens) return null; | |
π High v2/oversizedSession.ts:24
After multiple requests that each fit the context window, this check can still classify an unrelated InvalidRequestError as an oversized session because inputTokens is cumulative across steps. That replaces the real error with a false instruction to fork or start over; use per-request context usage such as turn.lastStep instead.
Also found in 1 other location(s)
packages/provider-opencode/src/server/v2/adapter.ts:3719
turn.usage.inputis cumulative across steps (session.step.ended/failedadds each step's input at adapter.ts:2168), not the session's context size. For example, three 80k-token steps in a 200k window produce 240k here despite every request fitting. A subsequent unrelatedInvalidRequestErrorthen loses its original message and falsely tells the user the session is irrecoverably oversized and must be forked/replaced. Use per-request context evidence (such asturn.lastStep, already used for context usage at lines 1625β1628), rather than aggregate billed input, for this check.
π€ Copy this AI Prompt to have your agent fix this:
| 1 | In file @packages/provider-opencode/src/server/v2/oversizedSession.ts around line 24: |
| 2 | |
| 3 | After multiple requests that each fit the context window, this check can still classify an unrelated `InvalidRequestError` as an oversized session because `inputTokens` is cumulative across steps. That replaces the real error with a false instruction to fork or start over; use per-request context usage such as `turn.lastStep` instead. |
| 4 | |
| 5 | Also found in 1 other location(s): |
| 6 | - packages/provider-opencode/src/server/v2/adapter.ts:3719 -- `turn.usage.input` is cumulative across steps (`session.step.ended`/`failed` adds each step's input at adapter.ts:2168), not the session's context size. For example, three 80k-token steps in a 200k window produce 240k here despite every request fitting. A subsequent unrelated `InvalidRequestError` then loses its original message and falsely tells the user the session is irrecoverably oversized and must be forked/replaced. Use per-request context evidence (such as `turn.lastStep`, already used for context usage at lines 1625β1628), rather than aggregate billed input, for this check. |