Your team of AI agents, on your Mac, Windows or Linux. Agents that talk in channels, write code, review each other and use your tools, on the Claude Code, Codex, OpenCode or Pi you already have. Anything that touches the real world waits for your yes.
TypeScript agent-teamagentic-aiai-agentsai-assistantclaude-codecodexcursorelectrongrokgrok-bot-alternativelinuxlocal-firstmacosmcpmulti-agentopenclaw-alternativeopencodewindows
End a Claude reply as soon as its text ends (#108)
Dias9a4951ec1e42
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5fb8942..a45337c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,8 @@ What changed in each version of Tucano. The format follows [Keep a Changelog](ht### Fixed- **A thread opens at its latest message,** like in Slack, instead of at the message that started it: a long thread no longer has to be scrolled all the way down to see where it is. Scrolling up still stays put when a reply comes in.+- **Claude replies finish about 2 seconds sooner, at times 10.** After each reply Claude Code made one more model call, a summary of the turn that Tucano never reads, and only then said it was done and exited. That call is now off for the Claude Code that Tucano runs, so a reply ends when its text does, and what waits on it (the next agent in line, a team's report) starts right away. Your own Claude Code in the terminal isn't touched.+- **Agents see what a connector returns, even when it's long.** A result over Claude Code's own cut (about 50 KB, like the comments of a big merge request) was saved to a file the agent can't read, so it called again and again and answered without the data. Tucano now cuts a result at 40 KB, counted in bytes so accents don't push it over, and tells the agent to ask again with pagination or a filter if it needs the rest.## [0.2.10] - 2026-11-04diff --git a/src/core/engines/claude.ts b/src/core/engines/claude.tsindex 6ea1da2..94b23aa 100644--- a/src/core/engines/claude.ts+++ b/src/core/engines/claude.ts@@ -167,6 +167,13 @@ export function claudeParser(): Parser {}}+// Without CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC the CLI makes one more model call after the+// reply (its post-turn summary) and only then sends `result` and exits: about 2.5 s on every+// reply, at times over 10 s. Nobody reads that summary here, and the CLI runs one reply and goes.+export function claudeEnv(p: Provider, account?: string): NodeJS.ProcessEnv {+ return { ...process.env, CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1', ...p.env, ...(account ? { CLAUDE_CONFIG_DIR: account } : {}), MCP_TOOL_TIMEOUT: '900000' }+}+export function claudeEngine(bin: () => string | undefined, provider: () => Promise<Provider> = async () => userProvider()): Engine {return {id: 'claude',@@ -178,7 +185,7 @@ export function claudeEngine(bin: () => string | undefined, provider: () => Prom}// The gateway's token goes in the environment, never in the arguments (other processes can read those).const p = await provider()- yield* runCli({ bin: path, args: claudeArgs(turn, p.apiKeyHelper), stdin: claudeInput(turn), cwd: turn.cwd, signal: turn.signal, parser: claudeParser(), env: { ...process.env, ...p.env, ...(turn.account ? { CLAUDE_CONFIG_DIR: turn.account } : {}), MCP_TOOL_TIMEOUT: '900000' } })+ yield* runCli({ bin: path, args: claudeArgs(turn, p.apiKeyHelper), stdin: claudeInput(turn), cwd: turn.cwd, signal: turn.signal, parser: claudeParser(), env: claudeEnv(p, turn.account) })}}}diff --git a/src/core/runs.ts b/src/core/runs.tsindex 9976189..d2e4c62 100644--- a/src/core/runs.ts+++ b/src/core/runs.ts@@ -32,7 +32,10 @@ const MAX_MENTIONS = 3const MAX_DEPTH = 3 // agent replies chained from one human messageconst DELTA_FLUSH_MS = 40const RETRYABLE: RunStatus[] = ['failed', 'stopped', 'interrupted', 'limit_reached']-const MAX_RESULT_CHARS = 60_000 // per tool result handed back to the model+// Per tool result handed back to the model, in UTF-8 bytes. Under Claude Code's own cut (about 50 KB,+// or 25k tokens): past it the CLI saves the result to a file and tells the model to read it, which it+// can't here (no file tools), so it calls again and again and answers without the data.+export const MAX_RESULT_BYTES = 40_000const REASON_PARAM = '_motivo'const OVER_CALLS_GRACE = 3 // calls refused past the budget before the turn is cutconst BUDGET_OVERRUN = 1.3 // past the budget by this much without wrapping up, the turn is cut@@ -107,7 +110,14 @@ export function resultText(r: CallToolResult): string {const text = r.content.map((c) => (c.type === 'text' ? c.text : `[${c.type}]`)).join('\n')- return text.length > MAX_RESULT_CHARS ? `${text.slice(0, MAX_RESULT_CHARS)}\n${L(`[… resultado cortado em ${MAX_RESULT_CHARS} caracteres]`, `[… result cut at ${MAX_RESULT_CHARS} characters]`)}` : text+ const bytes = Buffer.from(text, 'utf8')+ if (bytes.length <= MAX_RESULT_BYTES) return text+ // Cut on a whole character: a split one decodes as U+FFFD at the end.+ const kept = bytes.subarray(0, MAX_RESULT_BYTES).toString('utf8').replace(/�+$/, '')+ return `${kept}\n${L(+ `[… resultado cortado em ${MAX_RESULT_BYTES / 1000} KB: o resto não chegou. Se precisar dele, chame de novo pedindo menos de uma vez (paginação, filtro, menos campos).]`,+ `[… result cut at ${MAX_RESULT_BYTES / 1000} KB: the rest didn't come through. If you need it, call again asking for less at once (pagination, a filter, fewer fields).]`+ )}`}// Text is clipped; images go through (screenshots, charts), a few at most.diff --git a/test/faster-turns.test.ts b/test/faster-turns.test.tsnew file mode 100644index 0000000..89c3ca1--- /dev/null+++ b/test/faster-turns.test.ts@@ -0,0 +1,39 @@+import { describe, expect, it } from 'vitest'+import { claudeEnv } from '../src/core/engines/claude'+import { MAX_RESULT_BYTES, resultText } from '../src/core/runs'++const text = (t: string) => ({ content: [{ type: 'text' as const, text: t }] })++describe('a tool result handed back to the model', () => {+ it('goes as it is under the cut', () => {+ const t = 'x'.repeat(MAX_RESULT_BYTES)+ expect(resultText(text(t))).toBe(t)+ })++ it('is cut in bytes under Claude Code’s own cut, and says how to get the rest', () => {+ const out = resultText(text('a'.repeat(60_000)))+ expect(Buffer.byteLength(out, 'utf8')).toBeLessThan(50_000)+ expect(out.startsWith('a'.repeat(MAX_RESULT_BYTES))).toBe(true)+ expect(out).toMatch(/pagina|paginat/i)+ })++ it('counts accents as the bytes they are, and never splits a character', () => {+ const out = resultText(text('ção '.repeat(20_000))) // 6 bytes each+ const kept = out.slice(0, out.lastIndexOf('\n'))+ expect(Buffer.byteLength(kept, 'utf8')).toBeLessThanOrEqual(MAX_RESULT_BYTES)+ expect(kept).not.toContain('�')+ })+})++describe('the environment Claude Code runs in', () => {+ it('turns off the post-turn summary that holds every reply', () => {+ expect(claudeEnv({ env: {} })['CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC']).toBe('1')+ })++ it('keeps the person’s own provider settings and the account', () => {+ const env = claudeEnv({ env: { ANTHROPIC_BASE_URL: 'https://gw.example' } }, '/accounts/a')+ expect(env['ANTHROPIC_BASE_URL']).toBe('https://gw.example')+ expect(env['CLAUDE_CONFIG_DIR']).toBe('/accounts/a')+ expect(env['MCP_TOOL_TIMEOUT']).toBe('900000')+ })+})