fix(agents): validate LLMAgent tool dispatch against declared tools list #63
Labels
No labels
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
Depends on
#77 Epic: LLM Agent Runtime Stabilization — reliability, resource enforcement & correctness hardening
cleveragents/cleveractors-core
#64 fix(agents): validate tool name against declared tools list before dispatch
cleveragents/cleveractors-core
Reference
cleveragents/cleveractors-core#63
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Metadata
fix(agents): validate tool name against declared tools list before dispatchbugfix/m2-llmagent-tool-dispatch-validationBackground and context
The multi-turn tool-call loop introduced in commit
227e2fe(issue #59) dispatches tool calls returned by the LLM by spawning a transientToolAgentwhosetoolslist contains only the tool name the LLM requested. However, there is no check that the requested tool name is actually present in theLLMAgent's ownself._lc_tools— the list built from the actor'stools:config at construction time.ToolAgent.__init__validates the requested name againstbuiltin_tools(the eight hardcoded built-ins registered at startup), not against the actor's configuredtools:list. Because all eight standard built-ins are unconditionally accepted, an LLM that has been prompt-injected can callfile_read,file_write,http_request, or any other built-in regardless of which tools the actor config actually declared.Current behavior
When the LLM returns a tool call,
LLMAgentexecutes (insrc/cleveractors/agents/llm.py, repeated in each of the three tool-round branches):tool_nameis taken verbatim fromtc.get("name", "")orfn_def.get("name", "")with no membership check againstself._lc_tools.Expected behavior
Before spawning the transient
ToolAgent,LLMAgentmust verify thattool_nameappears in the set of names declared inself._lc_tools. If the name is absent, the tool call should produce aToolMessagewith an appropriate error (e.g."Tool 'X' is not available") and the loop should continue so the LLM can recover, rather than silently executing an undeclared tool.Suggested guard (same logic applies to all three loop branches):
Acceptance criteria
self._lc_tools, aToolMessagewith an error string is appended and the loop continues; the undeclared tool is never executed.self._lc_tools, execution proceeds as before — no regression.features/llm_agent_tool_calling.featurecovering the undeclared-tool case.noxsessions pass (unit_tests,coverage_report≥ 97%,typecheck,lint).Subtasks
src/cleveractors/agents/llm.pythat construct the transientToolAgent_declared_namesmembership check before eachToolAgentinstantiationScenario: LLMAgent rejects tool calls for tools not in the declared listnox -s unit_testsand confirm new scenario passesnox -s coverage_reportand confirm ≥ 97%nox(all default sessions) and confirm fully greenDefinition of Done
This issue is complete when:
I do not think this report is actually true, because there is a safeguard in:
src/cleveractors/tool.pymethod _execute_tool:it just needs to be adjusted to:
but for clear feedback to the main agent i've kept the suggested code snippet.