GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(opencode): add input limit for compaction (#8465) · bpd1069/opencode@8d720f9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/opencode
    • src
      • plugin
        • codex.ts
      • provider
        • models.ts
        • provider.ts
      • session
        • compaction.ts
    • test/session
      • compaction.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/src/plugin/codex.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/plugin/codex.ts
-32Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -361,38 +361,6 @@ export async function CodexAuthPlugin(input: PluginInput): Promise<Hooks> {
361361
}
362362
}
363363

364-
if (!provider.models["gpt-5.2-codex"]) {
365-
const model = {
366-
id: "gpt-5.2-codex",
367-
providerID: "openai",
368-
api: {
369-
id: "gpt-5.2-codex",
370-
url: "https://chatgpt.com/backend-api/codex",
371-
npm: "@ai-sdk/openai",
372-
},
373-
name: "GPT-5.2 Codex",
374-
capabilities: {
375-
temperature: false,
376-
reasoning: true,
377-
attachment: true,
378-
toolcall: true,
379-
input: { text: true, audio: false, image: true, video: false, pdf: false },
380-
output: { text: true, audio: false, image: false, video: false, pdf: false },
381-
interleaved: false,
382-
},
383-
cost: { input: 0, output: 0, cache: { read: 0, write: 0 } },
384-
limit: { context: 400000, output: 128000 },
385-
status: "active" as const,
386-
options: {},
387-
headers: {},
388-
release_date: "2025-12-18",
389-
variants: {} as Record<string, Record<string, any>>,
390-
family: "gpt-codex",
391-
}
392-
model.variants = ProviderTransform.variants(model)
393-
provider.models["gpt-5.2-codex"] = model
394-
}
395-
396364
// Zero out costs for Codex (included with ChatGPT subscription)
397365
for (const model of Object.values(provider.models)) {
398366
model.cost = {
Collapse file

‎packages/opencode/src/provider/models.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/provider/models.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export namespace ModelsDev {
4747
.optional(),
4848
limit: z.object({
4949
context: z.number(),
50+
input: z.number().optional(),
5051
output: z.number(),
5152
}),
5253
modalities: z
Collapse file

‎packages/opencode/src/provider/provider.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/provider/provider.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ export namespace Provider {
557557
}),
558558
limit: z.object({
559559
context: z.number(),
560+
input: z.number().optional(),
560561
output: z.number(),
561562
}),
562563
status: z.enum(["alpha", "beta", "deprecated", "active"]),
@@ -619,6 +620,7 @@ export namespace Provider {
619620
},
620621
limit: {
621622
context: model.limit.context,
623+
input: model.limit.input,
622624
output: model.limit.output,
623625
},
624626
capabilities: {
Collapse file

‎packages/opencode/src/session/compaction.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/session/compaction.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export namespace SessionCompaction {
3434
if (context === 0) return false
3535
const count = input.tokens.input + input.tokens.cache.read + input.tokens.output
3636
const output = Math.min(input.model.limit.output, SessionPrompt.OUTPUT_TOKEN_MAX) || SessionPrompt.OUTPUT_TOKEN_MAX
37-
const usable = context - output
37+
const usable = input.model.limit.input || context - output
3838
return count > usable
3939
}
4040

Collapse file

‎packages/opencode/test/session/compaction.test.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/test/session/compaction.test.ts
+43-1Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ import type { Provider } from "../../src/provider/provider"
1010

1111
Log.init({ print: false })
1212

13-
function createModel(opts: { context: number; output: number; cost?: Provider.Model["cost"] }): Provider.Model {
13+
function createModel(opts: {
14+
context: number
15+
output: number
16+
input?: number
17+
cost?: Provider.Model["cost"]
18+
}): Provider.Model {
1419
return {
1520
id: "test-model",
1621
providerID: "test",
1722
name: "Test",
1823
limit: {
1924
context: opts.context,
25+
input: opts.input,
2026
output: opts.output,
2127
},
2228
cost: opts.cost ?? { input: 0, output: 0, cache: { read: 0, write: 0 } },
@@ -70,6 +76,42 @@ describe("session.compaction.isOverflow", () => {
7076
})
7177
})
7278

79+
test("respects input limit for input caps", async () => {
80+
await using tmp = await tmpdir()
81+
await Instance.provide({
82+
directory: tmp.path,
83+
fn: async () => {
84+
const model = createModel({ context: 400_000, input: 272_000, output: 128_000 })
85+
const tokens = { input: 271_000, output: 1_000, reasoning: 0, cache: { read: 2_000, write: 0 } }
86+
expect(await SessionCompaction.isOverflow({ tokens, model })).toBe(true)
87+
},
88+
})
89+
})
90+
91+
test("returns false when input/output are within input caps", async () => {
92+
await using tmp = await tmpdir()
93+
await Instance.provide({
94+
directory: tmp.path,
95+
fn: async () => {
96+
const model = createModel({ context: 400_000, input: 272_000, output: 128_000 })
97+
const tokens = { input: 200_000, output: 20_000, reasoning: 0, cache: { read: 10_000, write: 0 } }
98+
expect(await SessionCompaction.isOverflow({ tokens, model })).toBe(false)
99+
},
100+
})
101+
})
102+
103+
test("returns false when output within limit with input caps", async () => {
104+
await using tmp = await tmpdir()
105+
await Instance.provide({
106+
directory: tmp.path,
107+
fn: async () => {
108+
const model = createModel({ context: 200_000, input: 120_000, output: 10_000 })
109+
const tokens = { input: 50_000, output: 9_999, reasoning: 0, cache: { read: 0, write: 0 } }
110+
expect(await SessionCompaction.isOverflow({ tokens, model })).toBe(false)
111+
},
112+
})
113+
})
114+
73115
test("returns false when model context limit is 0", async () => {
74116
await using tmp = await tmpdir()
75117
await Instance.provide({

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.