Skip to content

Commit 754c748

Browse files
jeremyederclaude
andcommitted
fix(runner): resolve PR review feedback for SDK bump
- Add messageId to reasoning cleanup end events so clients can correlate start/end events and avoid orphaning in-flight reasoning blocks - Auto-migrate deprecated max_thinking_tokens to ThinkingConfigEnabled in forwarded_props for forward compatibility with SDK changes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bdd51a5 commit 754c748

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

components/runners/ambient-runner/ag_ui_claude_sdk/adapter.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,10 +1132,19 @@ def flush_pending_msg():
11321132
logger.debug("Cleanup: closing hanging thinking block")
11331133
ts = now_ms()
11341134
yield ReasoningMessageEndEvent(
1135-
threadId=thread_id, runId=run_id, timestamp=ts
1135+
threadId=thread_id,
1136+
runId=run_id,
1137+
messageId=current_reasoning_id,
1138+
timestamp=ts,
1139+
)
1140+
yield ReasoningEndEvent(
1141+
threadId=thread_id,
1142+
runId=run_id,
1143+
messageId=current_reasoning_id,
1144+
timestamp=ts,
11361145
)
1137-
yield ReasoningEndEvent(threadId=thread_id, runId=run_id, timestamp=ts)
11381146
in_thinking_block = False
1147+
current_reasoning_id = None
11391148

11401149
if has_streamed_text and current_message_id:
11411150
logger.debug(

components/runners/ambient-runner/ag_ui_claude_sdk/utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,22 @@ def apply_forwarded_props(
300300
if not forwarded_props or not isinstance(forwarded_props, dict):
301301
return merged_kwargs
302302

303+
# Migrate deprecated max_thinking_tokens → thinking config
304+
if (
305+
"max_thinking_tokens" in forwarded_props
306+
and "thinking" not in forwarded_props
307+
and forwarded_props["max_thinking_tokens"] is not None
308+
):
309+
from claude_agent_sdk.types import ThinkingConfigEnabled
310+
311+
budget = forwarded_props.pop("max_thinking_tokens")
312+
forwarded_props["thinking"] = ThinkingConfigEnabled(budget_tokens=budget)
313+
logger.warning(
314+
"max_thinking_tokens is deprecated; converted to "
315+
"thinking=ThinkingConfigEnabled(budget_tokens=%d)",
316+
budget,
317+
)
318+
303319
applied_count = 0
304320
for key, value in forwarded_props.items():
305321
# Only apply whitelisted keys

0 commit comments

Comments
 (0)