Skip to content

Commit 11b4c18

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 11b4c18

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

docs/developers/sdk-typescript.md

Lines changed: 11 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,11 @@ await q.setPermissionMode('yolo');
143143
// Change model mid-session
144144
await q.setModel('qwen-max');
145145

146+
// Get context window usage breakdown (token counts per category)
147+
const usage = await q.getContextUsage();
148+
// Pass true to hint that per-item details should be displayed
149+
const detail = await q.getContextUsage(true);
150+
146151
// Close the session
147152
await q.close();
148153
```

0 commit comments

Comments
 (0)