From d81144992f522593dc4f225d4054eb1695be1df0 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 19 Feb 2026 08:01:43 +0100 Subject: pkg/aflow: fix handling of optional tool arguments Currently we crash on nil deref, if LLM specifies explicit 'nil' for an optional (pointer) argument. Handle such cases properly. Fixes #6811 --- pkg/aflow/testdata/TestNilToolArg.trajectory.json | 98 +++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 pkg/aflow/testdata/TestNilToolArg.trajectory.json (limited to 'pkg/aflow/testdata/TestNilToolArg.trajectory.json') diff --git a/pkg/aflow/testdata/TestNilToolArg.trajectory.json b/pkg/aflow/testdata/TestNilToolArg.trajectory.json new file mode 100644 index 000000000..518e8a26b --- /dev/null +++ b/pkg/aflow/testdata/TestNilToolArg.trajectory.json @@ -0,0 +1,98 @@ +[ + { + "Seq": 0, + "Nesting": 0, + "Type": "flow", + "Name": "test", + "Started": "0001-01-01T00:00:01Z" + }, + { + "Seq": 1, + "Nesting": 1, + "Type": "agent", + "Name": "smarty", + "Model": "model", + "Started": "0001-01-01T00:00:02Z", + "Instruction": "Instructions\nPrefer calling several tools at the same time to save round-trips.\n", + "Prompt": "Initial Prompt" + }, + { + "Seq": 2, + "Nesting": 2, + "Type": "llm", + "Name": "smarty", + "Model": "model", + "Started": "0001-01-01T00:00:03Z" + }, + { + "Seq": 2, + "Nesting": 2, + "Type": "llm", + "Name": "smarty", + "Model": "model", + "Started": "0001-01-01T00:00:03Z", + "Finished": "0001-01-01T00:00:04Z" + }, + { + "Seq": 3, + "Nesting": 2, + "Type": "tool", + "Name": "tool", + "Started": "0001-01-01T00:00:05Z", + "Args": { + "Optional": null + } + }, + { + "Seq": 3, + "Nesting": 2, + "Type": "tool", + "Name": "tool", + "Started": "0001-01-01T00:00:05Z", + "Finished": "0001-01-01T00:00:06Z", + "Error": "missing argument \"Optional\"", + "Args": { + "Optional": null + } + }, + { + "Seq": 4, + "Nesting": 2, + "Type": "llm", + "Name": "smarty", + "Model": "model", + "Started": "0001-01-01T00:00:07Z" + }, + { + "Seq": 4, + "Nesting": 2, + "Type": "llm", + "Name": "smarty", + "Model": "model", + "Started": "0001-01-01T00:00:07Z", + "Finished": "0001-01-01T00:00:08Z" + }, + { + "Seq": 1, + "Nesting": 1, + "Type": "agent", + "Name": "smarty", + "Model": "model", + "Started": "0001-01-01T00:00:02Z", + "Finished": "0001-01-01T00:00:09Z", + "Instruction": "Instructions\nPrefer calling several tools at the same time to save round-trips.\n", + "Prompt": "Initial Prompt", + "Reply": "Result" + }, + { + "Seq": 0, + "Nesting": 0, + "Type": "flow", + "Name": "test", + "Started": "0001-01-01T00:00:01Z", + "Finished": "0001-01-01T00:00:10Z", + "Results": { + "Result": "Result" + } + } +] \ No newline at end of file -- cgit mrf-deployment