dify icon indicating copy to clipboard operation
dify copied to clipboard

Agent v2 activity shows a failed tool after the same call retries and succeeds

Open mikamikasuki opened this issue 3 weeks ago • 1 comments

Self Checks

  • [x] I have read the Contributing Guide and Language Policy.
  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report, otherwise it will be closed.
  • [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

main (609c2a98fb7f54ce956250ae420f58fe89141b95)

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Create a Chatflow or Workflow with an Agent v2 node and a function tool.
  2. Trigger a tool retry: the first attempt returns a validation error or ModelRetry, then the model retries the same tool call with corrected arguments and the tool returns successfully. Dify's pinned Pydantic AI 2.53.0 represents the retry and corrected call with the same tool_call_id.
  3. Inspect the live tool activity for that call after the successful result.

The corresponding event sequence is function_tool_call(id=X), function_tool_result(part_kind=retry-prompt, id=X), function_tool_call(id=X), then function_tool_result(part_kind=tool-return, id=X, outcome=success).

✔️ Expected Behavior

The retry should remain nonterminal. The same activity should transition back to running with the corrected arguments and then to succeeded with the successful output.

❌ Actual Behavior

The first retry-prompt event is projected as a terminal failed activity. Because subsequent events use the same tool_call_id, the projector ignores the corrected call and its successful result, leaving the UI stuck on a failed status with no final output.

mikamikasuki avatar Nov 13 '26 09:11 mikamikasuki

One useful detail for triage: the existing tests explicitly encode the premature failure. In api/tests/unit_tests/core/workflow/nodes/agent_v2/test_tool_activity.py, both test_retry_prompt_result_marks_call_failed and test_real_retry_prompt_event_through_adapter_fails_call expect failed immediately after the retry prompt; neither continues through the corrected call and successful result. Your four-event sequence would make a useful regression case alongside those tests. [1] [2]

This is upstream of rendering: the projector rejects the corrected call unless the stored state is started, and rejects results once the state is terminal. The chat activity handler, by contrast, replaces an existing activity with a matching execution ID and activity ID without a terminal-status guard. That points to the backend projector and its retry-state handling as the place to address this, rather than a UI-only change. [3] [4]

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about dify with Dosu

dosubot[bot] avatar Nov 13 '26 09:11 dosubot[bot]