mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-03 04:12:37 +02:00
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:
parent
54948e567f
commit
79e16e65f6
3 changed files with 129 additions and 1 deletions
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class Processor(AgentService):
|
|||
)
|
||||
|
||||
self.agent = AgentManager(
|
||||
tools=[],
|
||||
tools={},
|
||||
additional_context="",
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue