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(adapters,server): output budgets, adapter queue memory, and per-key model policy by lidge-jun · Pull Request #5265 · lidge-jun/opencodex

fix(adapters,server): output budgets, adapter queue memory, and per-key model policy #5265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
lidge-jun merged 6 commits into dev from codex/260920-lane-e-budgets-key-policy
Sep 20, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(adapters,server): output budgets, adapter queue memory, and per-key model policy #5265

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit Hold shift + click to select a range
d2d0aea
fix(devin): send the configured output budget instead of the encoder …
lidge-jun Sep 20, 2026
793a72f
feat(coding-agent): derive the projected-history ceiling from the mod…
lidge-jun Sep 20, 2026
a233fe4
fix(adapters): bound the event queue by retained payload, not by even…
lidge-jun Sep 20, 2026
92a0496
feat(server): scope an admission key to the models and providers it m…
lidge-jun Sep 20, 2026
c4a105b
docs(devlog): record lane E of the phase 2 consolidation batch
lidge-jun Sep 20, 2026
6a4b584
fix(server,adapters): close the virtual-model scope gap and harden qu…
lidge-jun Sep 20, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Next Next commit
fix(devin): send the configured output budget instead of the encoder …
…default

Codex never sends max_output_tokens, and the devin adapter only forwarded a
caller-supplied value, so every devin turn was capped at the cloud-direct
encoder's 8192 fallback however the provider was configured. A turn that
legitimately needed more ended as an upstream incomplete/max_output_tokens the
client then retried into the same deterministic wall.

Resolve the cap the way the other adapters do, highest authority first: an
explicit caller value forwarded unchanged, then the configured per-model cap,
then the provider default, then the encoder fallback. The lookup is the same
UID-aware hint resolution the input ceiling already uses, extracted so both
sides read a per-model number identically.

The output cap and the history ceiling stay separate. CompletionConfiguration
#2 is the output cap and #3 is the context window, so the resolver reads
neither contextWindow nor modelContextWindows -- collapsing them would ask
Cognition to generate a whole context window of output.

Also stop OAuth startup reconciliation from deleting an operator's output
budget. No OAuth preset declares defaultMaxOutputTokens or
modelMaxOutputTokens, so the delete-when-preset-undefined branch was the only
branch either field ever took and a hand-edited value was wiped before the
next startup finished. A preset that does declare one still refreshes the row.

Closes #5190
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@lidge-jun
lidge-jun committed Sep 20, 2026
commit d2d0aea74d8166bbb45d64dc83554db9eb87933b

There are no files selected for viewing

3 changes: 2 additions & 1 deletion 3 scripts/test-layout/layout.json
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,8 @@
"web-search-sidecar-429.test.ts": "web-search",
"management-google-tool-schema-policy.test.ts": "server",
"codex-shim-destroyed-probe.test.ts": "codex-integration",
"client-runtime.test.ts": "clients"
"client-runtime.test.ts": "clients",
"devin-output-budget.test.ts": "providers"
},
"migrated": [
"adapters",
Expand Down
95 changes: 72 additions & 23 deletions 95 src/adapters/devin.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,35 @@ async function resolveWireModelUid(
*/
export const resolveWireModelUidForTests = resolveWireModelUid;

const positiveTokenCount = (value: unknown): number | undefined =>
typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : undefined;

/**
* Read a per-model token count for the exact UID selected for this turn.
*
* Tries the selected UID and then its collapsed base id, preferring the
* canonical spelling and accepting dotted or case-folded saved hints — the same
* normalization the inference request applies to the model id. Where several
* spellings match one id, the smallest wins: a ceiling stated twice is
* satisfied by the lower statement.
*/
function devinModelTokenHint(
record: Record<string, number> | undefined,
modelUid: string,
): number | undefined {
if (!record) return undefined;
for (const id of [modelUid, collapseDevinModelUid(modelUid)]) {
const exact = Object.hasOwn(record, id) ? positiveTokenCount(record[id]) : undefined;
if (exact !== undefined) return exact;
const matches = Object.entries(record)
.filter(([key]) => normalizeDevinModelId(key).toLowerCase() === id.toLowerCase())
.map(([, value]) => positiveTokenCount(value))
.filter((value): value is number => value !== undefined);
if (matches.length > 0) return Math.min(...matches);
}
return undefined;
}

/**
* Resolve the INPUT ceiling for the exact UID selected for this turn. Catalog
* ClientModelConfig #18 and CompletionConfiguration #3 both carry input tokens;
Expand All @@ -204,33 +233,50 @@ function resolveDevinMaxInputTokens(
modelUid: string,
liveWindow?: number,
): number | undefined {
const positive = (value: unknown): number | undefined =>
typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : undefined;
const baseId = collapseDevinModelUid(modelUid);
const configured = (record: Record<string, number> | undefined): number | undefined => {
if (!record) return undefined;
for (const id of [modelUid, baseId]) {
// Prefer the canonical spelling; retain dotted/case-folded saved hints,
// matching the model-id normalization used for the inference request.
const exact = Object.hasOwn(record, id) ? positive(record[id]) : undefined;
if (exact !== undefined) return exact;
const matches = Object.entries(record)
.filter(([key]) => normalizeDevinModelId(key).toLowerCase() === id.toLowerCase())
.map(([, value]) => positive(value))
.filter((value): value is number => value !== undefined);
if (matches.length > 0) return Math.min(...matches);
}
return undefined;
};
const contextHint = configured(provider.modelContextWindows) ?? positive(provider.contextWindow);
const inputHint = configured(provider.modelMaxInputTokens);
const ceilings = [positive(liveWindow), contextHint, inputHint]
const contextHint = devinModelTokenHint(provider.modelContextWindows, modelUid)
?? positiveTokenCount(provider.contextWindow);
const inputHint = devinModelTokenHint(provider.modelMaxInputTokens, modelUid);
const ceilings = [positiveTokenCount(liveWindow), contextHint, inputHint]
.filter((value): value is number => value !== undefined);
return ceilings.length > 0 ? Math.min(...ceilings) : undefined;
}

/** Pure test seam; runtime uses the same resolver immediately before dispatch. */
/**
* Resolve the OUTPUT ceiling for this turn, highest authority first:
*
* 1. the caller's explicit `max_output_tokens`, forwarded unchanged — an
* explicit cap is a request, so a small one is never widened into a
* configured larger one;
* 2. the configured per-model cap (`modelMaxOutputTokens`), read through the
* same UID-aware hint lookup the input ceiling uses;
* 3. the provider-wide `defaultMaxOutputTokens`;
* 4. undefined, which leaves the cloud-direct encoder's own 8192 fallback in
* place for a provider that configured nothing.
*
* This is NOT the history ceiling, and the two must not collapse into one
* number. CompletionConfiguration #2 is the output cap and #3 is the context
* window, so feeding a context window into this resolver would ask Cognition to
* generate a whole window's worth of output. Nothing here reads
* `contextWindow` or `modelContextWindows` for that reason.
*
* Step 1 keeps the caller's raw value rather than `positiveTokenCount`: the
* inbound parser owns what a caller may send, and re-filtering here would
* silently promote a rejected value to a configured cap the caller never asked
* for.
*/
function resolveDevinMaxOutputTokens(
provider: OcxProviderConfig,
modelUid: string,
requested: number | undefined,
): number | undefined {
if (typeof requested === "number") return requested;
return devinModelTokenHint(provider.modelMaxOutputTokens, modelUid)
?? positiveTokenCount(provider.defaultMaxOutputTokens);
}

/** Pure test seams; runtime uses the same resolvers immediately before dispatch. */
export const resolveDevinMaxInputTokensForTests = resolveDevinMaxInputTokens;
export const resolveDevinMaxOutputTokensForTests = resolveDevinMaxOutputTokens;

export class DevinMissingCredentialError extends Error {
constructor() {
Expand Down Expand Up @@ -590,6 +636,9 @@ export function createDevinAdapter(
const maxInputTokens = resolveDevinMaxInputTokens(
provider, modelUid, catalog?.byUid.get(modelUid)?.contextWindow,
);
const maxOutputTokens = resolveDevinMaxOutputTokens(
provider, modelUid, parsed.options.maxOutputTokens,
);
// The reset-retry wrapper waits out a 429 that states its own recovery
// delay ("limit will reset in 35 seconds") and replays the identical
// request — but only while zero events have been yielded, so a
Expand All @@ -606,7 +655,7 @@ export function createDevinAdapter(
// input hint used to force every model through the 128k default.
completionOpts: {
...(maxInputTokens !== undefined ? { maxInputTokens } : {}),
...(typeof parsed.options.maxOutputTokens === "number" ? { maxOutputTokens: parsed.options.maxOutputTokens } : {}),
...(maxOutputTokens !== undefined ? { maxOutputTokens } : {}),
...(typeof parsed.options.temperature === "number" ? { temperature: parsed.options.temperature } : {}),
...(typeof parsed.options.topP === "number" ? { topP: parsed.options.topP } : {}),
},
Expand Down
25 changes: 24 additions & 1 deletion 25 src/oauth/index.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,29 @@ const OAUTH_RECONCILE_FIELDS: (keyof OcxProviderConfig)[] = [
// existing rows through enrichProviderFromRegistry, which is fill-only and
// preserves explicit saved values.

/**
* Output-budget fields an OAuth preset may refresh but must never erase.
*
* These stay on the reconcile list so a preset that does declare a budget still
* refreshes the saved row. What changes is the other branch: when the preset
* declares nothing, the operator's value survives instead of being deleted.
*
* Without that, the fields behaved as if they could not be configured at all.
* No OAuth preset seeds either one, so the delete branch was the only branch
* these two ever took, and a hand-edited `defaultMaxOutputTokens` was gone
* before the first turn of the next startup — leaving the adapter's own
* fallback as the only reachable output cap (#5190).
*
* Scoped to the output budget on purpose. The input side (`contextWindow`,
* `modelContextWindows`) describes what the account's models are, which the
* preset and live discovery do own; an output budget is a spend decision the
* operator makes.
*/
const OAUTH_PRESERVE_WHEN_PRESET_UNSET: ReadonlySet<keyof OcxProviderConfig> = new Set([
"defaultMaxOutputTokens",
"modelMaxOutputTokens",
]);

const GOOGLE_ANTIGRAVITY_PROVIDER = "google-antigravity";
const GOOGLE_ANTIGRAVITY_LIVE_DISCOVERY_VERSION = 2 as const;

Expand Down Expand Up @@ -1312,7 +1335,7 @@ function applyOAuthPresetCatalog(
if (JSON.stringify(provider[field]) === JSON.stringify(preset[field])) continue;
if (preset[field] !== undefined) {
provider[field] = cloneProviderField(preset[field]) as never;
} else {
} else if (!OAUTH_PRESERVE_WHEN_PRESET_UNSET.has(field)) {
delete provider[field];
}
}
Expand Down
3 changes: 2 additions & 1 deletion 3 tests/fixtures/test-layout-expected.json
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1398,5 +1398,6 @@
"gui-codex-usage-score-parity.test.ts": "gui",
"web-search-sidecar-429.test.ts": "web-search",
"codex-shim-destroyed-probe.test.ts": "codex-integration",
"client-runtime.test.ts": "clients"
"client-runtime.test.ts": "clients",
"devin-output-budget.test.ts": "providers"
}
37 changes: 37 additions & 0 deletions 37 tests/oauth/oauth-provider-reconcile.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,43 @@ describe("OAuth provider reconciliation", () => {
expect(config.providers.kimi.requiresReasoningPlaceholderModels).toEqual([]);
});

test("preserves an operator output budget that no OAuth preset declares", () => {
// The devin preset declares neither output field, so the delete branch was
// the only branch either of them ever took: a hand-edited budget was gone
// before the next startup finished, leaving the adapter's own fallback as
// the only reachable cap (#5190). Reconciliation still owns the input-side
// catalog, which is why modelContextWindows is asserted alongside.
const preset = OAUTH_PROVIDERS.devin.providerConfig;
expect(preset.defaultMaxOutputTokens).toBeUndefined();
expect(preset.modelMaxOutputTokens).toBeUndefined();
const config = {
port: 10100,
defaultProvider: "devin",
googleAntigravityStaticCatalogVersion: 1,
providers: {
devin: {
...structuredClone(preset),
defaultMaxOutputTokens: 64_000,
modelMaxOutputTokens: { "swe-2": 32_000 },
modelContextWindows: { "swe-2": 1 },
},
},
} satisfies OcxConfig;

reconcileOAuthProviders(config, false);

expect(config.providers.devin.defaultMaxOutputTokens).toBe(64_000);
expect(config.providers.devin.modelMaxOutputTokens).toEqual({ "swe-2": 32_000 });
expect(config.providers.devin.modelContextWindows).toEqual(preset.modelContextWindows!);

// A preset that does declare a budget still refreshes the saved row: this
// is a narrower delete branch, not an exemption from reconciliation.
config.providers.devin.defaultMaxOutputTokens = 1;
reconcileOAuthProviders(config, false);
expect(config.providers.devin.defaultMaxOutputTokens).toBe(1);
expect(OAUTH_PROVIDERS.anthropic.providerConfig.defaultMaxOutputTokens).toBeGreaterThan(0);
});

test("refreshes Grok 4.6 levels while runtime fills the default without overwriting user intent", () => {
const home = mkdtempSync(join(tmpdir(), "ocx-grok-46-reconcile-"));
homes.push(home);
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.