Skip to content

Add opt-in id parameter to ToolCall.from_name#349

Merged
jamesbraza merged 1 commit intomainfrom
toolcall-from-name-id
Apr 7, 2026
Merged

Add opt-in id parameter to ToolCall.from_name#349
jamesbraza merged 1 commit intomainfrom
toolcall-from-name-id

Conversation

@jamesbraza
Copy link
Copy Markdown
Collaborator

Summary

ToolCall.from_tool already accepts an optional id kwarg, but ToolCall.from_name always auto-generated one. This adds the same opt-in pattern to from_name for callers that need a deterministic or pre-existing tool call ID.

🤖 Generated with Claude Code

Matches the existing pattern in `ToolCall.from_tool`, which already
accepts an optional `id` kwarg.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jamesbraza jamesbraza self-assigned this Apr 7, 2026
Copilot AI review requested due to automatic review settings April 7, 2026 21:45
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 7, 2026
@jamesbraza jamesbraza added the enhancement New feature or request label Apr 7, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns ToolCall.from_name with ToolCall.from_tool by allowing callers to optionally supply a pre-existing/deterministic tool-call ID instead of always auto-generating one.

Changes:

  • Add an optional ID argument to ToolCall.from_name, falling back to generate_id() when not provided.
  • Extend tool serialization tests to verify custom IDs propagate through execution and into ToolResponseMessage.tool_call_id.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/aviary/tools/base.py Adds an optional identifier parameter to ToolCall.from_name and uses it when provided.
tests/test_tools.py Adds a subtest ensuring a custom tool-call ID is preserved through tool execution/response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/aviary/tools/base.py
Comment thread src/aviary/tools/base.py
@jamesbraza jamesbraza changed the title Add opt-in id parameter to ToolCall.from_name Add opt-in call_id parameter to ToolCall.from_name Apr 7, 2026
@jamesbraza jamesbraza force-pushed the toolcall-from-name-id branch from f2ae15b to dc5eddd Compare April 7, 2026 22:11
@jamesbraza jamesbraza changed the title Add opt-in call_id parameter to ToolCall.from_name Add opt-in id parameter to ToolCall.from_name Apr 7, 2026
@jamesbraza jamesbraza merged commit cd77d65 into main Apr 7, 2026
13 of 14 checks passed
@jamesbraza jamesbraza deleted the toolcall-from-name-id branch April 7, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants