dify/api/tests/unit_tests
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
..
clients refactor: introduce agent working environment architecture (#39480) 2026-07-28 13:16:05 +00:00
commands ci: replace custom noqa markers with guard ignores (#39679) 2026-07-28 08:52:12 +00:00
configs feat(agent): separate CLI file URL audiences (#39952) 2026-08-04 13:14:02 +00:00
controllers feat(agent): separate CLI file URL audiences (#39952) 2026-08-04 13:14:02 +00:00
core test(agent): pin the colliding case and state why the rule is shaped this way 2026-08-05 18:57:51 -07:00
dev feat(dataset): expose New RAG KnowledgeFS contracts (#39314) 2026-07-23 01:48:36 +00:00
enterprise/telemetry test: more caplog (#38452) 2026-07-08 08:24:31 +00:00
enums refactor: quota v3 integration (#35436) 2026-04-27 01:49:40 +00:00
events test: enforce strict typing in migrated unit tests (#39689) 2026-07-28 14:04:56 +00:00
extensions fix(api): bump OpenTelemetry to stop duplicate Flask context detach (#39921) 2026-08-04 02:17:53 +00:00
factories feat(workflow): support LLM environment variables (#39125) 2026-08-04 06:17:13 +00:00
fields feat: make skill package upload size limit configurable (#39799) 2026-07-30 08:42:24 +00:00
libs feat(workflow): support human input in loop and iteration (#39243) 2026-08-03 02:24:18 +00:00
migrations feat(agent): make home snapshots optional and use backend defaults (#39702) 2026-07-29 02:01:12 +00:00
models test(agent): pin the colliding case and state why the rule is shaped this way 2026-08-05 18:57:51 -07:00
oss chore: add more type in test (#37609) 2026-06-18 23:07:12 +00:00
repositories fix: prevent hidden-tab collaboration leader from saving stale drafts (#38997) 2026-07-20 06:58:01 +00:00
services fix(agent): show one log entry per call when a tool repeats in a turn 2026-08-05 09:47:17 -07:00
tasks test: use caplog for telemetry error logging (#39722) 2026-07-30 09:32:56 +00:00
tools fix: fix mcp output_schema is optional (#39453) 2026-07-28 02:31:18 +00:00
utils chore: add Type to test (#37191) 2026-06-19 16:44:20 +00:00
__init__.py FEAT: NEW WORKFLOW ENGINE (#3160) 2024-04-08 18:51:46 +08:00
.gitignore Enhance Code Consistency Across Repository with .editorconfig (#19023) 2025-04-29 18:04:33 +08:00
.ruff.toml test: migrate account service tests to shared SQLite (#39758) 2026-07-29 11:43:32 +00:00
conftest.py test: share unbound unit test sessions (#39690) 2026-07-28 14:12:08 +00:00
pyrefly.toml feat(agent): separate CLI file URL audiences (#39952) 2026-08-04 13:14:02 +00:00
test_app_factory.py fix: gate service API, MCP and trigger surfaces on enterprise license (#39635) 2026-07-27 08:23:15 +00:00
test_makefile_backend_tests.py test(api): manage backend pytest services natively (#36235) 2026-05-19 07:52:15 +00:00
test_pytest_dify.py refactor: thread explicit sessions through app retrieval paths (#38309) 2026-07-02 17:00:47 +00:00
test_sqlite_fixtures.py test: share unbound unit test sessions (#39690) 2026-07-28 14:12:08 +00:00