Skip to content

Commit d468728

Browse files
wenshaoclaude
andcommitted
docs: add getContextUsage() to SDK TypeScript documentation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c45d69b commit d468728

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

docs/developers/sdk-typescript.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ Creates a new query session with the Qwen Code.
7979

8080
The SDK enforces the following default timeouts:
8181

82-
| Timeout | Default | Description |
83-
| ---------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- |
84-
| `canUseTool` | 1 minute | Maximum time for `canUseTool` callback to respond. If exceeded, the tool request is auto-denied. |
85-
| `mcpRequest` | 1 minute | Maximum time for SDK MCP tool calls to complete. |
86-
| `controlRequest` | 1 minute | Maximum time for control operations like `initialize()`, `setModel()`, `setPermissionMode()`, and `interrupt()` to complete. |
87-
| `streamClose` | 1 minute | Maximum time to wait for initialization to complete before closing CLI stdin in multi-turn mode with SDK MCP servers. |
82+
| Timeout | Default | Description |
83+
| ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
84+
| `canUseTool` | 1 minute | Maximum time for `canUseTool` callback to respond. If exceeded, the tool request is auto-denied. |
85+
| `mcpRequest` | 1 minute | Maximum time for SDK MCP tool calls to complete. |
86+
| `controlRequest` | 1 minute | Maximum time for control operations like `initialize()`, `setModel()`, `setPermissionMode()`, `getContextUsage()`, and `interrupt()` to complete. |
87+
| `streamClose` | 1 minute | Maximum time to wait for initialization to complete before closing CLI stdin in multi-turn mode with SDK MCP servers. |
8888

8989
You can customize these timeouts via the `timeout` option:
9090

@@ -143,6 +143,10 @@ await q.setPermissionMode('yolo');
143143
// Change model mid-session
144144
await q.setModel('qwen-max');
145145

146+
// Get context window usage breakdown
147+
const usage = await q.getContextUsage(); // summary only
148+
const detail = await q.getContextUsage(true); // per-item breakdown
149+
146150
// Close the session
147151
await q.close();
148152
```

0 commit comments

Comments
 (0)