diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2026-01-26 15:07:40 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-01-26 15:57:53 +0000 |
| commit | 2c2305d0192e0c8b78037c441e5fe4f8d7cccbf1 (patch) | |
| tree | 698c5178df061c90b46b8428b60a0aa541ec1423 /pkg | |
| parent | 4964e02465f2e9b4f98fbbf49f2fe058892b715d (diff) | |
pkg/aflow: keep LLM reply on tool calls
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/aflow/flow_test.go | 3 | ||||
| -rw-r--r-- | pkg/aflow/llm_agent.go | 5 | ||||
| -rw-r--r-- | pkg/aflow/testdata/TestWorkflow.llm.json | 6 | ||||
| -rw-r--r-- | pkg/aflow/testdata/TestWorkflow.trajectory.json | 2 |
4 files changed, 15 insertions, 1 deletions
diff --git a/pkg/aflow/flow_test.go b/pkg/aflow/flow_test.go index 203ff798c..2a03d82d0 100644 --- a/pkg/aflow/flow_test.go +++ b/pkg/aflow/flow_test.go @@ -188,6 +188,9 @@ func TestWorkflow(t *testing.T) { }, }, { + Text: "Some non-thoughts reply along with tool calls", + }, + { Text: "I am thinking I need to call some tools", Thought: true, }, diff --git a/pkg/aflow/llm_agent.go b/pkg/aflow/llm_agent.go index 2c83be2eb..692443ac3 100644 --- a/pkg/aflow/llm_agent.go +++ b/pkg/aflow/llm_agent.go @@ -347,6 +347,11 @@ func (a *LLMAgent) parseResponse(resp *genai.GenerateContentResponse, span *traj if strings.TrimSpace(reply) == "" { reply = "" } + // If there is any reply along with tool calls, append it to thoughts. + // Otherwise it won't show up in the trajectory anywhere. + if len(calls) != 0 && reply != "" { + span.Thoughts += "\n" + reply + } return } diff --git a/pkg/aflow/testdata/TestWorkflow.llm.json b/pkg/aflow/testdata/TestWorkflow.llm.json index 681552571..d7e490daa 100644 --- a/pkg/aflow/testdata/TestWorkflow.llm.json +++ b/pkg/aflow/testdata/TestWorkflow.llm.json @@ -321,6 +321,9 @@ } }, { + "text": "Some non-thoughts reply along with tool calls" + }, + { "text": "I am thinking I need to call some tools", "thought": true } @@ -524,6 +527,9 @@ } }, { + "text": "Some non-thoughts reply along with tool calls" + }, + { "text": "I am thinking I need to call some tools", "thought": true } diff --git a/pkg/aflow/testdata/TestWorkflow.trajectory.json b/pkg/aflow/testdata/TestWorkflow.trajectory.json index 3a4859bbf..ab3e49899 100644 --- a/pkg/aflow/testdata/TestWorkflow.trajectory.json +++ b/pkg/aflow/testdata/TestWorkflow.trajectory.json @@ -51,7 +51,7 @@ "Model": "model1", "Started": "0001-01-01T00:00:05Z", "Finished": "0001-01-01T00:00:06Z", - "Thoughts": "I am thinking I need to call some tools" + "Thoughts": "I am thinking I need to call some tools\nSome non-thoughts reply along with tool calls" }, { "Seq": 4, |
