Skip to content

Fix repeated Deep Agents tool calls with identical arguments - #1806

Open
1fanwang wants to merge 1 commit into
temporalio:mainfrom
1fanwang:fix/deepagents-distinct-tool-call-cache
Open

Fix repeated Deep Agents tool calls with identical arguments#1806
1fanwang wants to merge 1 commit into
temporalio:mainfrom
1fanwang:fix/deepagents-distinct-tool-call-cache

Conversation

@1fanwang

@1fanwang 1fanwang commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What was changed

When a Deep Agent requested the same tool and arguments twice in one workflow,
only the first call ran. The second call returned the first result without
scheduling its Temporal Activity.

run_deep_agent caches activity results for continue-as-new. The tool cache key
now includes the call ID as well as the tool name and arguments. Separate calls
run independently, while replay of the same call can still reuse its result.

Why?

Before this fix, a side-effecting tool requested twice with identical arguments
ran only once. After the fix, workflow history records two
deepagents.invoke_tool Activity schedules.

Checklist

  1. Closes

No issue. This is a small, self-contained bug fix.

  1. How was this tested:

The regression test drives a real Deep Agents workflow against a local Temporal
server and makes two tool calls with the same arguments but different call IDs.

Red on main
$ git checkout origin/main -- temporalio/contrib/deepagents/workflow.py
$ uv run pytest tests/contrib/deepagents/test_tools.py::test_repeated_tool_calls_with_same_args_both_run -q --no-header --tb=short -p no:pretty
E   assert 1 == 2
FAILED tests/contrib/deepagents/test_tools.py::test_repeated_tool_calls_with_same_args_both_run
1 failed, 18 warnings in 3.58s
Green with this fix
$ git checkout HEAD -- temporalio/contrib/deepagents/workflow.py
$ uv run pytest tests/contrib/deepagents/test_tools.py::test_repeated_tool_calls_with_same_args_both_run -q --no-header --tb=short -p no:pretty
.                                                                        [100%]
  1. Any docs updates needed?

The changelog includes the corrected behavior. The public API is unchanged.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
@1fanwang
1fanwang requested review from a team as code owners September 2, 2026 07:58
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.

1 participant