[PR #29126] feat: Support 'return_direct' mechanism and fix critical multi-tool data loss bug #32304

Open
opened 2026-02-21 20:51:09 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/29126

State: open
Merged: No


Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

close #29122
This PR introduces a return_direct mechanism for Agent tools, allowing them to bypass the final LLM inference step and return results directly. This is particularly useful for tools generating large structured data (e.g., ECharts, huge tables) where LLM processing is unnecessary and costly.

Some modifications are compromises made to ensure consistency with the current front-end rendering, and annotations have been added to explain this part.

To enable the Return Direct mechanism (bypassing the final LLM inference), simply include a return_direct key in the tool's output dictionary with a value of True.

Example (Workflow as Tool): In the End Node of your workflow, add a new output variable named return_direct and set its value to True (Boolean). The Agent Runner will detect this signal and return the tool's output immediately.

Additionally, this PR fixes a high-severity bug in fc_agent_runner.py where multiple calls to the same tool in a single iteration caused data loss.

Critical Bug Analysis in fc_agent_runner.py
The original code contains a critical bug regarding parallel tool calls. Let's illustrate this with a concrete example:

Scenario: Suppose we have a tool named query_stock_price. We want the Agent to query the stock prices of Apple (AAPL) and Google (GOOG) simultaneously in a single step.

The model generates two tool call requests:

query_stock_price with {"symbol": "AAPL"}

query_stock_price with {"symbol": "GOOG"}

Inside fc_agent_runner.py, this results in a tool_calls list similar to this:

Python

tool_calls = [
('call_id_1', 'query_stock_price', {'symbol': 'AAPL'}),
('call_id_2', 'query_stock_price', {'symbol': 'GOOG'})
]
Where is the bug? Let's look at how the original code processes this list to generate inputs (the logic for observations has the same issue):

Original Code (Buggy):

Python

tool_call_inputs = json.dumps(
{tool_call[1]: tool_call[2] for tool_call in tool_calls}
)
This code uses a dictionary comprehension. When iterating through the list:

First Iteration: Processes ('call_id_1', 'query_stock_price', {'symbol': 'AAPL'}).

Dictionary entry created: {'query_stock_price': {'symbol': 'AAPL'}}.

Second Iteration: Processes ('call_id_2', 'query_stock_price', {'symbol': 'GOOG'}).

The dictionary key is still 'query_stock_price'.

In Python dictionaries, keys must be unique. Therefore, the new value {'symbol': 'GOOG'} overwrites the old value {'symbol': 'AAPL'}.

Final Result: The generated dictionary is {'query_stock_price': {'symbol': 'GOOG'}}. Consequently, the request for AAPL is completely lost! The agent will only execute the query for GOOG.

Screenshots

Before After
... ...

Since the before-and-after results do not correspond one-to-one, I have detailed them below using screenshots and text descriptions.

This is a comparison of API calls before and after:
{
"inputs": {},
"query": "使用测试工具",
"response_mode": "streaming",
"conversation_id": "",
"user": "abc-123"
}
before (No return_direct set):
data: {"event":"agent_thought","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"e4137a61-567c-44b5-9112-ddf60a8b6bcb","position":1,"thought":"","observation":"","tool":"","tool_labels":{},"tool_input":"","message_files":[]}

data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":""}

data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":""}

data: {"event":"agent_thought","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"e4137a61-567c-44b5-9112-ddf60a8b6bcb","position":1,"thought":"","observation":"","tool":"AASAS","tool_labels":{"AASAS":{"en_US":"AASAS","zh_Hans":"AASAS"}},"tool_input":"{"AASAS": {}}","message_files":[]}

data: {"event":"agent_thought","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"e4137a61-567c-44b5-9112-ddf60a8b6bcb","position":1,"thought":"","observation":"{"AASAS": "{\"text\": \"这���一个测试吗? \\n好的\"}"}","tool":"AASAS","tool_labels":{"AASAS":{"en_US":"AASAS","zh_Hans":"AASAS"}},"tool_input":"{"AASAS": {}}","message_files":[]}

data: {"event":"agent_thought","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"a7444e2f-f551-42da-87ac-565bcaf88029","position":2,"thought":"","observation":"","tool":"","tool_labels":{},"tool_input":"","message_files":[]}

data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":"这是一个"}

data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":"测试"}

data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":"吗"}

data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":"?"}

data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":" \n"}

data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":"好的"}

data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":""}

data: {"event":"agent_thought","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"a7444e2f-f551-42da-87ac-565bcaf88029","position":2,"thought":"这是一个测试吗? \n好的","observation":"","tool":"","tool_labels":{},"tool_input":"","message_files":[]}

data: {"event":"message_end","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","metadata":{"annotation_reply":null,"retriever_resources":[],"usage":{"prompt_tokens":958,"prompt_unit_price":"0","prompt_price_unit":"0","prompt_price":"0","completion_tokens":24,"completion_unit_price":"0","completion_price_unit":"0","completion_price":"0","total_tokens":982,"total_price":"0","currency":"USD","latency":2.0799175053834915,"time_to_first_token":null,"time_to_generate":null}},"files":null}

after(return_direct =True):
data: {"event":"agent_thought","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"cbfacfa7-c44d-41ab-b72f-3550398e27c5","position":1,"thought":"","observation":"","tool":"","tool_labels":{},"tool_input":"","message_files":[]}

data: {"event":"agent_message","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","answer":""}

data: {"event":"agent_message","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","answer":""}

data: {"event":"agent_thought","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"cbfacfa7-c44d-41ab-b72f-3550398e27c5","position":1,"thought":"","observation":"","tool":"1","tool_labels":{"1":{"en_US":"1","zh_Hans":"1"}},"tool_input":"{"1": {"return_direct": true}}","message_files":[]}

data: {"event":"agent_thought","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"cbfacfa7-c44d-41ab-b72f-3550398e27c5","position":1,"thought":"","observation":"{"1": "这是一个测试吗? \n好的\n2025-12-04 07:02:44\n[{\"date\": \"2025-12-04\", \"time\": \"07:02:44\"}]\n{\"prompt_tokens\": 496, \"prompt_unit_price\": \"0\", \"prompt_price_unit\": \"0\", \"prompt_price\": \"0\", \"completion_tokens\": 33, \"completion_unit_price\": \"0\", \"completion_price_unit\": \"0\", \"completion_price\": \"0\", \"total_tokens\": 529, \"total_price\": \"0\", \"currency\": \"USD\", \"latency\": 0.45659293700009584, \"time_to_first_token\": null, \"time_to_generate\": null}"}","tool":"1","tool_labels":{"1":{"en_US":"1","zh_Hans":"1"}},"tool_input":"{"1": {"return_direct": true}}","message_files":[]}

data: {"event":"agent_thought","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"e3d1d208-bcb0-47c3-867b-1625f5460c90","position":2,"thought":"这是一个测试吗? \n好的\n2025-12-04 07:02:44\n[{"date": "2025-12-04", "time": "07:02:44"}]\n{"prompt_tokens": 496, "prompt_unit_price": "0", "prompt_price_unit": "0", "prompt_price": "0", "completion_tokens": 33, "completion_unit_price": "0", "completion_price_unit": "0", "completion_price": "0", "total_tokens": 529, "total_price": "0", "currency": "USD", "latency": 0.45659293700009584, "time_to_first_token": null, "time_to_generate": null}","observation":"","tool":"","tool_labels":{},"tool_input":"","message_files":[]}

data: {"event":"agent_message","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","answer":""}

data: {"event":"message_end","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","metadata":{"annotation_reply":null,"retriever_resources":[],"usage":{"prompt_tokens":135,"prompt_unit_price":"0","prompt_price_unit":"0","prompt_price":"0","completion_tokens":19,"completion_unit_price":"0","completion_price_unit":"0","completion_price":"0","total_tokens":154,"total_price":"0","currency":"USD","latency":2.306309378000151,"time_to_first_token":null,"time_to_generate":null}},"files":null}

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/29126 **State:** open **Merged:** No --- > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #<issue number>`. ## Summary close #29122 **This PR introduces a return_direct mechanism for Agent tools, allowing them to bypass the final LLM inference step and return results directly. This is particularly useful for tools generating large structured data (e.g., ECharts, huge tables) where LLM processing is unnecessary and costly.** Some modifications are compromises made to ensure consistency with the current front-end rendering, and annotations have been added to explain this part. To enable the Return Direct mechanism (bypassing the final LLM inference), simply include a return_direct key in the tool's output dictionary with a value of True. Example (Workflow as Tool): In the End Node of your workflow, add a new output variable named return_direct and set its value to True (Boolean). The Agent Runner will detect this signal and return the tool's output immediately. **Additionally, this PR fixes a high-severity bug in fc_agent_runner.py where multiple calls to the same tool in a single iteration caused data loss.** Critical Bug Analysis in fc_agent_runner.py The original code contains a critical bug regarding parallel tool calls. Let's illustrate this with a concrete example: Scenario: Suppose we have a tool named query_stock_price. We want the Agent to query the stock prices of Apple (AAPL) and Google (GOOG) simultaneously in a single step. The model generates two tool call requests: query_stock_price with {"symbol": "AAPL"} query_stock_price with {"symbol": "GOOG"} Inside fc_agent_runner.py, this results in a tool_calls list similar to this: Python tool_calls = [ ('call_id_1', 'query_stock_price', {'symbol': 'AAPL'}), ('call_id_2', 'query_stock_price', {'symbol': 'GOOG'}) ] Where is the bug? Let's look at how the original code processes this list to generate inputs (the logic for observations has the same issue): Original Code (Buggy): Python tool_call_inputs = json.dumps( {tool_call[1]: tool_call[2] for tool_call in tool_calls} ) This code uses a dictionary comprehension. When iterating through the list: First Iteration: Processes ('call_id_1', 'query_stock_price', {'symbol': 'AAPL'}). Dictionary entry created: {'query_stock_price': {'symbol': 'AAPL'}}. Second Iteration: Processes ('call_id_2', 'query_stock_price', {'symbol': 'GOOG'}). The dictionary key is still 'query_stock_price'. In Python dictionaries, keys must be unique. Therefore, the new value {'symbol': 'GOOG'} overwrites the old value {'symbol': 'AAPL'}. Final Result: The generated dictionary is {'query_stock_price': {'symbol': 'GOOG'}}. Consequently, the request for AAPL is completely lost! The agent will only execute the query for GOOG. ## Screenshots | Before | After | |--------|-------| | ... | ... | **Since the before-and-after results do not correspond one-to-one, I have detailed them below using screenshots and text descriptions.** This is a comparison of API calls before and after: { "inputs": {}, "query": "使用测试工具", "response_mode": "streaming", "conversation_id": "", "user": "abc-123" } before (No return_direct set): data: {"event":"agent_thought","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"e4137a61-567c-44b5-9112-ddf60a8b6bcb","position":1,"thought":"","observation":"","tool":"","tool_labels":{},"tool_input":"","message_files":[]} data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":""} data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":""} data: {"event":"agent_thought","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"e4137a61-567c-44b5-9112-ddf60a8b6bcb","position":1,"thought":"","observation":"","tool":"AASAS","tool_labels":{"AASAS":{"en_US":"AASAS","zh_Hans":"AASAS"}},"tool_input":"{\"AASAS\": {}}","message_files":[]} data: {"event":"agent_thought","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"e4137a61-567c-44b5-9112-ddf60a8b6bcb","position":1,"thought":"","observation":"{\"AASAS\": \"{\\\"text\\\": \\\"这���一个测试吗? \\\\n好的\\\"}\"}","tool":"AASAS","tool_labels":{"AASAS":{"en_US":"AASAS","zh_Hans":"AASAS"}},"tool_input":"{\"AASAS\": {}}","message_files":[]} data: {"event":"agent_thought","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"a7444e2f-f551-42da-87ac-565bcaf88029","position":2,"thought":"","observation":"","tool":"","tool_labels":{},"tool_input":"","message_files":[]} data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":"这是一个"} data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":"测试"} data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":"吗"} data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":"?"} data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":" \n"} data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":"好的"} data: {"event":"agent_message","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","answer":""} data: {"event":"agent_thought","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"a7444e2f-f551-42da-87ac-565bcaf88029","position":2,"thought":"这是一个测试吗? \n好的","observation":"","tool":"","tool_labels":{},"tool_input":"","message_files":[]} data: {"event":"message_end","conversation_id":"5b6a52c4-437b-4c7f-bdde-d71fa5c43181","message_id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","created_at":1764831812,"task_id":"c8d87cb3-e595-4c52-9e23-21a7bde39162","id":"61ebaab7-105e-4f20-91f0-dcf0d824295f","metadata":{"annotation_reply":null,"retriever_resources":[],"usage":{"prompt_tokens":958,"prompt_unit_price":"0","prompt_price_unit":"0","prompt_price":"0","completion_tokens":24,"completion_unit_price":"0","completion_price_unit":"0","completion_price":"0","total_tokens":982,"total_price":"0","currency":"USD","latency":2.0799175053834915,"time_to_first_token":null,"time_to_generate":null}},"files":null} after(return_direct =True): data: {"event":"agent_thought","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"cbfacfa7-c44d-41ab-b72f-3550398e27c5","position":1,"thought":"","observation":"","tool":"","tool_labels":{},"tool_input":"","message_files":[]} data: {"event":"agent_message","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","answer":""} data: {"event":"agent_message","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","answer":""} data: {"event":"agent_thought","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"cbfacfa7-c44d-41ab-b72f-3550398e27c5","position":1,"thought":"","observation":"","tool":"1","tool_labels":{"1":{"en_US":"1","zh_Hans":"1"}},"tool_input":"{\"1\": {\"return_direct\": true}}","message_files":[]} data: {"event":"agent_thought","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"cbfacfa7-c44d-41ab-b72f-3550398e27c5","position":1,"thought":"","observation":"{\"1\": \"这是一个测试吗? \\n好的\\n2025-12-04 07:02:44\\n[{\\\"date\\\": \\\"2025-12-04\\\", \\\"time\\\": \\\"07:02:44\\\"}]\\n{\\\"prompt_tokens\\\": 496, \\\"prompt_unit_price\\\": \\\"0\\\", \\\"prompt_price_unit\\\": \\\"0\\\", \\\"prompt_price\\\": \\\"0\\\", \\\"completion_tokens\\\": 33, \\\"completion_unit_price\\\": \\\"0\\\", \\\"completion_price_unit\\\": \\\"0\\\", \\\"completion_price\\\": \\\"0\\\", \\\"total_tokens\\\": 529, \\\"total_price\\\": \\\"0\\\", \\\"currency\\\": \\\"USD\\\", \\\"latency\\\": 0.45659293700009584, \\\"time_to_first_token\\\": null, \\\"time_to_generate\\\": null}\"}","tool":"1","tool_labels":{"1":{"en_US":"1","zh_Hans":"1"}},"tool_input":"{\"1\": {\"return_direct\": true}}","message_files":[]} data: {"event":"agent_thought","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"e3d1d208-bcb0-47c3-867b-1625f5460c90","position":2,"thought":"这是一个测试吗? \n好的\n2025-12-04 07:02:44\n[{\"date\": \"2025-12-04\", \"time\": \"07:02:44\"}]\n{\"prompt_tokens\": 496, \"prompt_unit_price\": \"0\", \"prompt_price_unit\": \"0\", \"prompt_price\": \"0\", \"completion_tokens\": 33, \"completion_unit_price\": \"0\", \"completion_price_unit\": \"0\", \"completion_price\": \"0\", \"total_tokens\": 529, \"total_price\": \"0\", \"currency\": \"USD\", \"latency\": 0.45659293700009584, \"time_to_first_token\": null, \"time_to_generate\": null}","observation":"","tool":"","tool_labels":{},"tool_input":"","message_files":[]} data: {"event":"agent_message","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","answer":""} data: {"event":"message_end","conversation_id":"d51383a2-3616-4cb2-a24c-1a4794bc233d","message_id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","created_at":1764831763,"task_id":"ea90c777-122b-4f7b-be2b-feed57adf381","id":"b6e84a57-a0a6-4d7a-851b-3749dbec400b","metadata":{"annotation_reply":null,"retriever_resources":[],"usage":{"prompt_tokens":135,"prompt_unit_price":"0","prompt_price_unit":"0","prompt_price":"0","completion_tokens":19,"completion_unit_price":"0","completion_price_unit":"0","completion_price":"0","total_tokens":154,"total_price":"0","currency":"USD","latency":2.306309378000151,"time_to_first_token":null,"time_to_generate":null}},"files":null} ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:51:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32304