Skip to content

Commit 2c2305d

Browse files
committed
pkg/aflow: keep LLM reply on tool calls
1 parent 4964e02 commit 2c2305d

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

pkg/aflow/flow_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ func TestWorkflow(t *testing.T) {
187187
},
188188
},
189189
},
190+
{
191+
Text: "Some non-thoughts reply along with tool calls",
192+
},
190193
{
191194
Text: "I am thinking I need to call some tools",
192195
Thought: true,

pkg/aflow/llm_agent.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ func (a *LLMAgent) parseResponse(resp *genai.GenerateContentResponse, span *traj
347347
if strings.TrimSpace(reply) == "" {
348348
reply = ""
349349
}
350+
// If there is any reply along with tool calls, append it to thoughts.
351+
// Otherwise it won't show up in the trajectory anywhere.
352+
if len(calls) != 0 && reply != "" {
353+
span.Thoughts += "\n" + reply
354+
}
350355
return
351356
}
352357

pkg/aflow/testdata/TestWorkflow.llm.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@
320320
"name": "tool2"
321321
}
322322
},
323+
{
324+
"text": "Some non-thoughts reply along with tool calls"
325+
},
323326
{
324327
"text": "I am thinking I need to call some tools",
325328
"thought": true
@@ -523,6 +526,9 @@
523526
"name": "tool2"
524527
}
525528
},
529+
{
530+
"text": "Some non-thoughts reply along with tool calls"
531+
},
526532
{
527533
"text": "I am thinking I need to call some tools",
528534
"thought": true

pkg/aflow/testdata/TestWorkflow.trajectory.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"Model": "model1",
5252
"Started": "0001-01-01T00:00:05Z",
5353
"Finished": "0001-01-01T00:00:06Z",
54-
"Thoughts": "I am thinking I need to call some tools"
54+
"Thoughts": "I am thinking I need to call some tools\nSome non-thoughts reply along with tool calls"
5555
},
5656
{
5757
"Seq": 4,

0 commit comments

Comments
 (0)