Skip to content

fix(runner): handle model-object tool calls in verbose logging#55

Open
Sai Asish Y (SAY-5) wants to merge 1 commit into
dedalus-labs:mainfrom
SAY-5:fix/verbose-tool-call-attribute-error
Open

fix(runner): handle model-object tool calls in verbose logging#55
Sai Asish Y (SAY-5) wants to merge 1 commit into
dedalus-labs:mainfrom
SAY-5:fix/verbose-tool-call-attribute-error

Conversation

@SAY-5
Copy link
Copy Markdown

Fixes #54.

DedalusRunner(..., verbose=True).run(..., tools=[...]) crashes with AttributeError on the first response containing tool calls. The verbose print paths call .get("function", {}) on tool-call entries, which works for the ToolCall TypedDicts produced by _extract_tool_calls but not for the SDK model objects read straight off API responses (e.g. in _execute_turns_sync at the Tool calls in response log line, and the message-history dumps).

This adds a small _tool_call_name(tc) helper that accepts either dicts or attribute-style model objects, and uses it in the affected verbose print paths. Non-verbose behavior is unchanged.

Test plan

  • New tests/test_runner_verbose.py: unit-tests _tool_call_name for dicts/model objects, and a regression test running runner.run(verbose=True, tools=[add]) against a mocked client returning model-style tool calls (fails on main, passes here).
  • pytest tests/test_local_scheduler.py tests/test_runner_verbose.py green.
  • ruff check/ruff format --check clean on changed files.

@cursor
Copy link
Copy Markdown

cursor Bot commented May 12, 2026

PR Summary

Low Risk
Low risk: changes are confined to verbose-only logging paths and add targeted tests, with no impact to tool execution or API requests when not printing debug output.

Overview
Fixes DedalusRunner crashing in verbose=True mode when tool calls come back as SDK model objects (attribute-only) instead of dicts.

Adds a small _tool_call_name() helper to safely extract tool names from either shape and switches all verbose log sites to use it, plus a regression test that mocks model-style tool calls to ensure run(verbose=True) no longer raises and prints the correct tool name.

Reviewed by Cursor Bugbot for commit 69c4276. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread src/dedalus_labs/lib/runner/core.py
@SAY-5 Sai Asish Y (SAY-5) force-pushed the fix/verbose-tool-call-attribute-error branch from 90f77be to 69c4276 Compare May 12, 2026 20:54
@SAY-5
Copy link
Copy Markdown
Author

Good catch. Updated the two remaining verbose sites (the extracted-calls list and the end-of-stream summary) to go through _tool_call_name so model-object tool calls no longer fall back to an inconsistent value.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 69c4276. Configure here.

return (fn.get("name", "?") if isinstance(fn, dict) else getattr(fn, "name", "?")) or "?"
return getattr(getattr(tc, "function", None), "name", "?") or "?"
except Exception:
return "?"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline tool-call name logic not refactored to use helper

Low Severity

The new _tool_call_name helper consolidates tool-call name extraction and is used at seven verbose-logging sites, but the equivalent inline implementation in _execute_turns_async (around line 592–601) still duplicates this logic with its own isinstance/getattr branching. This creates an inconsistency where future changes to name-extraction logic would need updating in two places. Additionally, at line 615, the isinstance(tc, dict) / else getattr(tc, "id", "?") branch for tc_id is unreachable because _extract_tool_calls always returns dicts—this adds unnecessary complexity suggesting model objects can appear where they cannot.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 69c4276. Configure here.

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.

verbose=True crashes on any tool-calling response (AttributeError on ChatCompletionMessageToolCall)

1 participant