Skip to content

enabled thinking for haiku during code tool turns - #197

Merged
SummonShenron merged 1 commit into
mainfrom
feat/claude_thinking
Nov 27, 2026
Merged

SummonShenron merged 1 commit into
mainfrom
feat/claude_thinking

Conversation

@SummonShenron

Copy link
Copy Markdown
Owner

enabled thinking for haiku tool steps

@vercel

vercel Bot commented Nov 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
saapp Building Building Preview Nov 27, 2026 11:54pm UTC

@SummonShenron

Copy link
Copy Markdown
Owner Author

Sonic Assistant PR Overview

Summary

This PR enables Claude Haiku to use thinking blocks during code-related turns (edits and plans) to improve performance. This change addresses issues where Anthropic rejected requests due to message history modifications, by implementing a drop_block mechanism for these specific turns.

What changed

  • Model Logic (backend/models/models.py): Added coding_thinking_enabled() to check the CODING_THINKING environment variable (defaulting to "on"). Updated tool_agent_llm to accept a coding boolean; when true, it forces Haiku to use thinking with drop_block=True.
  • Workflow Integration (backend/services/agent_workflow.py): Updated the agent workflow to identify edit or plan turns and pass the coding flag to tool_agent_llm. It also now records code_thinking_turns via self_counters.
  • Metrics (backend/utils/self_counters.py): Added code_thinking_turns to the list of tracked metrics.
  • Testing: Added backend/tests/test_coding_thinking.py to verify the new logic. Updated backend/tests/test_claude_llm.py, backend/tests/test_code_plan_execute_model.py, and backend/tests/test_tool_model_setting.py to reflect the updated tool_agent_llm signature.

Where to look

  • backend/models/models.py: The docstring for tool_agent_llm provides critical context on why drop_block is necessary for Haiku during coding turns.
  • backend/services/agent_workflow.py: Observe how the loop_llm is instantiated and how the code_thinking_turns counter is triggered.
  • backend/tests/test_coding_thinking.py: This file contains the primary test suite for the new functionality.

Risks and gaps

  • The change introduces a new environment variable, CODING_THINKING, which defaults to "on".
  • The logic relies on drop_block=True to bypass 400 errors from Anthropic when message history is modified; this is a specific workaround for observed behavior on 2026-11-02.

Not fully covered by this overview (diff cut short: backend/utils/self_counters.py).

Updated for commit 4f580ce

@SummonShenron
SummonShenron merged commit b0c43b8 into main Nov 27, 2026
2 of 4 checks passed

This branch was successfully deployed

1 active deployment
Preview — 4f580cef Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants