dify/api/tests/unit_tests/core
dparkmit24 2c162109c5 test(agent): pin the colliding case and state why the rule is shaped this way
The occurrence selector tells a per-call list from a single call's list
value by length alone. One test pinned the side where that is
unambiguous -- a 3-element list against 2 calls, replayed whole. The side
that decides whether the rule is safe is the other one: a tool called n
times whose single stored value is a list of length n. That case was
decided by the rule and described by no test, so it read as an oversight
rather than a decision.

Pin it at both readers. The replay reader in base_agent_runner and the
display reader on MessageAgentThought each get a two-call record whose
one stored value is a two-element list, asserting that call 1 reads
element 0 and call 2 reads element 1 -- what the rule does today. The
name says what the case concedes rather than what it asserts.

The docstrings say why the asymmetry is tolerable. observation values
are always str: ToolEngine.agent_invoke is typed
-> tuple[str, list[str], ToolInvokeMeta] and both runners store element
0, so a list under a tool name is not a shape any writer produces and
the length check is defensive there. tool_input values are json.loads of
the model's arguments with no shape check, so a legacy list-valued input
is possible in principle, and that is the side the collision can reach.

The selector is defined twice, identically, because models/ importing
from core/agent/ is the worse layering trade and the reverse is odd.
Neither copy is in the wrong place, so each now names the other and says
the duplication is deliberate -- enough for a future editor to find both.

No behaviour change: the condition, the ordering and the fallback are
untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 18:57:51 -07:00
..
agent test(agent): pin the colliding case and state why the rule is shaped this way 2026-08-05 18:57:51 -07:00
app feat(agent): separate CLI file URL audiences (#39952) 2026-08-04 13:14:02 +00:00
base chore: add Type to test (#35942) 2026-05-09 03:16:22 +00:00
callback_handler test: use SQLite sessions in core callback_handler (#39081) 2026-07-31 12:54:20 +00:00
datasource test: use SQLite sessions in core datasource (#39104) 2026-07-28 05:22:18 +00:00
entities fix(api): delete custom models stored with legacy model_type values (#39708) 2026-07-30 01:12:26 +00:00
extension chore: add Type to test (#35942) 2026-05-09 03:16:22 +00:00
external_data_tool test: use sqlite3 session in test_api (#38736) 2026-07-16 10:38:33 +00:00
file test: use sqlite3 session in test_remote_fetcher (#38773) 2026-07-14 07:01:23 +00:00
helper fix(api): make SSRF-blocked error message actionable (#39867) 2026-08-02 02:48:44 +00:00
llm_generator test: use SQLite sessions in core llm_generator (#39070) 2026-07-31 12:54:00 +00:00
logging fix(api): prevent identity logging deadlock (#39449) 2026-07-23 09:08:04 +00:00
mcp feat(mcp): support MCP protocol 2025-06-18 for workflow-as-MCP server (version negotiation + structured output) (#37892) 2026-07-07 03:26:50 +00:00
memory test: use SQLite sessions in core memory (#39066) 2026-07-27 10:15:08 +00:00
model_runtime chore(api): upgrade graphon to v0.3.0 (#35469) 2026-05-09 07:30:03 +00:00
moderation chore: pass session explicitly in ApiModeration (#39885) 2026-08-03 02:33:18 +00:00
ops fix(agent): show one log entry per call when a tool repeats in a turn 2026-08-05 09:47:17 -07:00
plugin feat(api): isolate credentials from local packages (#39957) 2026-08-04 02:50:04 +00:00
prompt test: use sqlite3 session in test_extract_thread_messages (#38739) 2026-07-27 09:00:47 +00:00
rag test: use sqlite3 session in test_qa_index_processor (#38765) 2026-08-04 10:53:55 +00:00
repositories feat(workflow): support human input in loop and iteration (#39243) 2026-08-03 02:24:18 +00:00
schemas chore: Caplog type (#37603) 2026-06-18 18:53:13 +00:00
telemetry chore: add Type to test (#35942) 2026-05-09 03:16:22 +00:00
tools feat(agent): separate CLI file URL audiences (#39952) 2026-08-04 13:14:02 +00:00
trigger chore: reorg imports (#35308) 2026-04-16 08:50:02 +00:00
variables feat(workflow): support human input in loop and iteration (#39243) 2026-08-03 02:24:18 +00:00
workflow feat(agent): separate CLI file URL audiences (#39952) 2026-08-04 13:14:02 +00:00
__init__.py FEAT: NEW WORKFLOW ENGINE (#3160) 2024-04-08 18:51:46 +08:00
test_file.py chore(api): adapt Graphon 0.2.2 upgrade (#35377) 2026-04-18 11:16:24 +00:00
test_model_manager.py fix: sync 35528 (#35539) 2026-04-24 03:59:33 +00:00
test_provider_configuration.py test: use sqlite3 session in test_provider_configuration (#38689) 2026-07-15 04:54:49 +00:00
test_provider_manager.py fix(api): surface system quota exhaustion without fallback (#39986) 2026-08-04 08:49:25 +00:00
test_trigger_debug_event_selectors.py refactor(api): move workflow knowledge nodes and trigger nodes (#33445) 2026-03-15 15:24:59 +08:00