Agent SDK modelUsage.contextWindow reports 200k instead of 1M for Opus/Sonnet 4.6
Description
The Agent SDK v0.2.77 correctly identifies 1M-capable models internally (via the Vf() function in cli.js which checks for claude-sonnet-4 or opus-4-6), but the modelUsage field in result messages still reports contextWindow: 200000 instead of 1000000.
Reproduction
Using the Agent SDK's query() function:
import { query } from "@anthropic-ai/claude-agent-sdk";
const q = query({
prompt: "hello",
options: {
model: "claude-opus-4-6",
permissionMode: "bypassPermissions",
allowDangerouslySkipPermissions: true,
},
});
for await (const msg of q) {
if (msg.type === "result") {
console.log(msg.modelUsage);
// Output: { "claude-opus-4-6": { contextWindow: 200000, ... } }
// Expected: { "claude-opus-4-6": { contextWindow: 1000000, ... } }
}
}
Expected behavior
modelUsage["claude-opus-4-6"].contextWindow should return 1000000 for models that support 1M context, consistent with the internal Vf() check that already returns 1e6 for these models.
Actual behavior
contextWindow returns 200000 in the result payload, despite the SDK knowing the model supports 1M.
Impact
Any application using the Agent SDK to track context window occupancy (e.g. inputTokens / contextWindow for usage percentage) gets incorrect numbers. We currently maintain a manual override map to work around this:
const CONTEXT_WINDOW_1M: Record<string, number> = {
"claude-opus-4-6": 1_000_000,
"claude-sonnet-4-6": 1_000_000,
};
const effectiveWindow = CONTEXT_WINDOW_1M[modelKey] ?? mu?.contextWindow;
Environment
@anthropic-ai/claude-agent-sdk: 0.2.77- Claude Code CLI: 2.1.77
- Runtime: Bun 1.3.10
- OS: macOS
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗