Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Llama Index
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
Llama Index
Commits
857c5228
Unverified
Commit
857c5228
authored
1 month ago
by
Logan
Committed by
GitHub
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
fix agentworkflow tool call tracking (#17968)
parent
3c01c98d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llama-index-core/llama_index/core/agent/workflow/multi_agent_workflow.py
+15
-1
15 additions, 1 deletion
...e/llama_index/core/agent/workflow/multi_agent_workflow.py
with
15 additions
and
1 deletion
llama-index-core/llama_index/core/agent/workflow/multi_agent_workflow.py
+
15
−
1
View file @
857c5228
...
@@ -345,6 +345,12 @@ class AgentWorkflow(Workflow, PromptMixin, metaclass=AgentWorkflowMeta):
...
@@ -345,6 +345,12 @@ class AgentWorkflow(Workflow, PromptMixin, metaclass=AgentWorkflowMeta):
memory
:
BaseMemory
=
await
ctx
.
get
(
"
memory
"
)
memory
:
BaseMemory
=
await
ctx
.
get
(
"
memory
"
)
output
=
await
agent
.
finalize
(
ctx
,
ev
,
memory
)
output
=
await
agent
.
finalize
(
ctx
,
ev
,
memory
)
cur_tool_calls
:
List
[
ToolCallResult
]
=
await
ctx
.
get
(
"
current_tool_calls
"
,
default
=
[]
)
output
.
tool_calls
.
extend
(
cur_tool_calls
)
# type: ignore
await
ctx
.
set
(
"
current_tool_calls
"
,
[])
return
StopEvent
(
result
=
output
)
return
StopEvent
(
result
=
output
)
await
ctx
.
set
(
"
num_tool_calls
"
,
len
(
ev
.
tool_calls
))
await
ctx
.
set
(
"
num_tool_calls
"
,
len
(
ev
.
tool_calls
))
...
@@ -417,6 +423,13 @@ class AgentWorkflow(Workflow, PromptMixin, metaclass=AgentWorkflowMeta):
...
@@ -417,6 +423,13 @@ class AgentWorkflow(Workflow, PromptMixin, metaclass=AgentWorkflowMeta):
agent_name
:
str
=
await
ctx
.
get
(
"
current_agent_name
"
)
agent_name
:
str
=
await
ctx
.
get
(
"
current_agent_name
"
)
agent
:
BaseWorkflowAgent
=
self
.
agents
[
agent_name
]
agent
:
BaseWorkflowAgent
=
self
.
agents
[
agent_name
]
# track tool calls made during a .run() call
cur_tool_calls
:
List
[
ToolCallResult
]
=
await
ctx
.
get
(
"
current_tool_calls
"
,
default
=
[]
)
cur_tool_calls
.
extend
(
tool_call_results
)
await
ctx
.
set
(
"
current_tool_calls
"
,
cur_tool_calls
)
await
agent
.
handle_tool_call_results
(
ctx
,
tool_call_results
,
memory
)
await
agent
.
handle_tool_call_results
(
ctx
,
tool_call_results
,
memory
)
# set the next agent, if needed
# set the next agent, if needed
...
@@ -447,7 +460,7 @@ class AgentWorkflow(Workflow, PromptMixin, metaclass=AgentWorkflowMeta):
...
@@ -447,7 +460,7 @@ class AgentWorkflow(Workflow, PromptMixin, metaclass=AgentWorkflowMeta):
tool_name
=
t
.
tool_name
,
tool_name
=
t
.
tool_name
,
tool_kwargs
=
t
.
tool_kwargs
,
tool_kwargs
=
t
.
tool_kwargs
,
)
)
for
t
in
tool_call
_result
s
for
t
in
cur_
tool_calls
],
],
raw
=
str
(
return_direct_tool
.
tool_output
.
raw_output
),
raw
=
str
(
return_direct_tool
.
tool_output
.
raw_output
),
current_agent_name
=
agent
.
name
,
current_agent_name
=
agent
.
name
,
...
@@ -456,6 +469,7 @@ class AgentWorkflow(Workflow, PromptMixin, metaclass=AgentWorkflowMeta):
...
@@ -456,6 +469,7 @@ class AgentWorkflow(Workflow, PromptMixin, metaclass=AgentWorkflowMeta):
# we don't want to stop the system if we're just handing off
# we don't want to stop the system if we're just handing off
if
return_direct_tool
.
tool_name
!=
"
handoff
"
:
if
return_direct_tool
.
tool_name
!=
"
handoff
"
:
await
ctx
.
set
(
"
current_tool_calls
"
,
[])
return
StopEvent
(
result
=
result
)
return
StopEvent
(
result
=
result
)
user_msg_str
=
await
ctx
.
get
(
"
user_msg_str
"
)
user_msg_str
=
await
ctx
.
get
(
"
user_msg_str
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment