Fix/agent tool resilience (#461)

* Fix incorrect tool initialisation in agent service

* Make Action: parsing more resient.  If there are quotation marks, strip them off.

* Added test case for this change
This commit is contained in:
cybermaggedon 2025-08-21 13:00:33 +01:00 committed by GitHub
parent 54948e567f
commit 79e16e65f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 129 additions and 1 deletions

View file

@ -104,6 +104,13 @@ class AgentManager:
# Parse Action
if line.startswith("Action:"):
action = line[7:].strip()
# Get rid of quotation prefix/suffix if present
while action and action[0] == '"':
action = action[1:]
while action and action[-1] == '"':
action = action[:-1]
# Parse Args
if line.startswith("Args:"):
@ -250,9 +257,14 @@ class AgentManager:
await think(act.thought)
logger.debug(f"ACTION: {act.name}")
logger.debug(f"Tools: {self.tools.keys()}")
if act.name in self.tools:
action = self.tools[act.name]
else:
logger.debug(f"Tools: {self.tools}")
raise RuntimeError(f"No action for {act.name}!")
logger.debug(f"TOOL>>> {act}")

View file

@ -45,7 +45,7 @@ class Processor(AgentService):
)
self.agent = AgentManager(
tools=[],
tools={},
additional_context="",
)