Skip to content

(core): support duplicate tool policy specification - #6610

Merged
tinalenguyen merged 4 commits into
mainfrom
tina/duplicate-tool-calling-args
Aug 7, 2026
Merged

(core): support duplicate tool policy specification#6610
tinalenguyen merged 4 commits into
mainfrom
tina/duplicate-tool-calling-args

Conversation

@tinalenguyen

Copy link
Copy Markdown
Member

No description provided.

@tinalenguyen
tinalenguyen requested a review from a team as a code owner July 29, 2026 22:56

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review


on_duplicate: DuplicateMode
"""Behavior when a tool is called multiple times in the same context."""
on_duplicate: DuplicateMode | DuplicatePolicy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we add a separate arg like

@function_tool(on_duplicate="reject", duplicate_scope="name_and_args")

to not break user code if they are doing info.on_duplicate == "reject" ?

# argument, and a confirming re-call must key identically to the call it
# confirms — otherwise `confirm` + `name_and_args` would never match.
dup_key = _duplicate_key(
fnc_name=fnc_name, scope=duplicate_policy.scope, raw_arguments=raw_arguments

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

keying on raw_arguments may miss omitted / default parameters? like check_order(order_id="5") and check_order(order_id="5", locale=None) can be the same call with two different keys if locale has a default value and LLM may or may not include locale in the raw arguments. also, 1 vs 1.0?

maybe check duplicates after _prepare_function_arguments?

@longcw longcw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

something nit

# the confirm flag is harness state, not an argument: a confirming re-call has to
# key identically to the call it confirms
arguments = {k: v for k, v in arguments.items() if k != CONFIRM_DUPLICATE_PARAM}
return (fnc_name, _canonical_args(arguments))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_canonical_args is outside the try bock, is that expected to raise?

# derived AFTER the pop: CONFIRM_DUPLICATE_PARAM is harness state, not a tool
# argument, and a confirming re-call must key identically to the call it
# confirms — otherwise `confirm` + `name_and_args` would never match.
dup_key = _duplicate_key(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: skip this when on_duplicate == "allow"

exe_task: asyncio.Task[Any]
executor: _ToolExecutor
allow_cancellation: bool
duplicate_key: tuple[str, str | None] = ("", None)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: the default is not needed, and when on_duplicate == "allow" it can be None directly?

@tinalenguyen
tinalenguyen merged commit 54566fe into main Aug 7, 2026
23 checks passed
@tinalenguyen
tinalenguyen deleted the tina/duplicate-tool-calling-args branch August 7, 2026 02:46
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