dify/api/tests/unit_tests/core/ops
dparkmit24 c881abff0c fix(agent): show one log entry per call when a tool repeats in a turn
The console agent log builds one entry per name in the ";"-joined tool
column, then looks each name up in a dict keyed by tool name. A tool
called twice in one turn produced two entries reading the same key, so
both showed the same data -- the display the reproduction in #16220
describes.

Keeping every call's input and observation apart, as this branch already
did, changed what those two entries show without making them right: each
one showed both calls' data instead of one call's data twice.

Read the persisted payloads per call instead. MessageAgentThought now
exposes tool_inputs_per_call, tool_outputs_per_call and
tool_metas_per_call, one entry per entry in tools, in call order, and
get_agent_logs walks them alongside the names. A name whose stored value
is not one value per call gives the same value to each of its calls, so
every record written before those calls were kept apart renders exactly
as it renders today.

That makes tool_invoke_meta safe to group the same way, which it now is.
It carries the provider, the duration and the error the log shows for
each displayed call, so leaving it name-keyed would have left a repeated
tool showing the last call's provider and duration against both entries.
Its other reader, the tool trace, covers the tool rather than one call of
it and takes the last call's meta -- the only one it had before.

The occurrence selector moves to models.model so the reader that builds
the log and the reader that replays history share one definition. Its
behaviour is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 09:47:17 -07:00
..
__init__.py refactor: extract common url validator for config_entity.py (#21934) 2025-07-07 09:34:13 +08:00
test_base_trace_instance.py test: use sqlite3 session in test_base_trace_instance (#38744) 2026-07-24 03:55:32 +00:00
test_config_entity.py refactor(api): move trace providers (#35144) 2026-04-17 07:53:35 +00:00
test_lookup_helpers.py test: use SQLite sessions in core ops (#39072) 2026-07-27 10:41:17 +00:00
test_ops_trace_manager.py fix(agent): show one log entry per call when a tool repeats in a turn 2026-08-05 09:47:17 -07:00
test_trace_queue_manager.py chore: add Type to test (#35942) 2026-05-09 03:16:22 +00:00
test_trace_session_metadata.py test: use sqlite3 session in test_trace_session_metadata (#38750) 2026-07-13 06:05:07 +00:00
test_utils.py test: use sqlite3 session in test_utils (#38729) 2026-07-27 08:21:39 +00:00