Skip to content

Commit 39ab0c2

Browse files
Add MAX_THINKING_TOKENS env support and fix file-read-info format (#226)
PR for awareness and discussion. 1) claude-code-acp doesn't currently support configuring "maxThinkingTokens" (https://platform.claude.com/docs/en/agent-sdk/typescript) nor is it configured in the query. Result, at least for me, is that agent thinking chunks are never flowing through the chain. I added environment support to my ACP host, added env variable to query init for maxThinkingTokens following the pyton sdk env "MAX_THINKING_TOKENS". Result is now agent thinking chunks DO flow. And I can see Claude reason. Before, no chunks ever. This is perhaps based on configuration that Claude Agent SDK reads but could be made more flexibel. Such as this suggestions. 2) Fix file-read-info message: was showing nonsensical range format 'Read lines 160-40', now shows 'Read 40 lines starting at line 160'. The way this was written was confusing for myself and for Claude. If the file-read-info is supposed to give information, then lines like "Read lines 160-40" says absolutely nothing. Reproduce: Configure your ACP host to parse thinking tokens with no other external configuration. Claude will not send any. Enable maxThinkingTokens in ACP and set it to something like 8096. Try your ACP implementation again, Claude now sends thinking chunks. Bugs: Anthropic has a meta issue. Don't talk about the "thinking" tag with Claude. It will break output regardless of what client you use. (even on Claude Code CLI) --------- Co-authored-by: Ben Brandt <[email protected]>
1 parent 72a9cde commit 39ab0c2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/acp-agent.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,10 +670,16 @@ export class ClaudeAcpAgent implements Agent {
670670
extraArgs["session-id"] = sessionId;
671671
}
672672

673+
// Configure thinking tokens from environment variable
674+
const maxThinkingTokens = process.env.MAX_THINKING_TOKENS
675+
? parseInt(process.env.MAX_THINKING_TOKENS, 10)
676+
: undefined;
677+
673678
const options: Options = {
674679
systemPrompt,
675680
settingSources: ["user", "project", "local"],
676681
stderr: (err) => this.logger.error(err),
682+
...(maxThinkingTokens !== undefined && { maxThinkingTokens }),
677683
...userProvidedOptions,
678684
// Override certain fields that must be controlled by ACP
679685
cwd: params.cwd,

src/mcp-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ Usage:
175175

176176
if (result.wasLimited) {
177177
readInfo += `Read ${result.linesRead} lines (hit 50KB limit). `;
178-
} else {
179-
readInfo += `Read lines ${input.offset}-${result.linesRead}. `;
178+
} else if (input.offset && input.offset > 1) {
179+
readInfo += `Read lines ${input.offset}-${input.offset + result.linesRead}.`;
180180
}
181181

182182
if (result.wasLimited) {

0 commit comments

Comments
 (0)