diff --git a/.changeset/eighty-berries-tie.md b/.changeset/eighty-berries-tie.md new file mode 100644 index 0000000000000000000000000000000000000000..40756ad9dc6376d6dd1f52c3f4b5664c4594065f --- /dev/null +++ b/.changeset/eighty-berries-tie.md @@ -0,0 +1,5 @@ +--- +"create-llama": patch +--- + +Fix only produces one agent event diff --git a/templates/types/multiagent/fastapi/app/agents/planner.py b/templates/types/multiagent/fastapi/app/agents/planner.py index c81944e18f4faa427e17cb51c52f407f413921cd..07306f2ba7eb80e2dee6d4b29eb2d48a56f6b3de 100644 --- a/templates/types/multiagent/fastapi/app/agents/planner.py +++ b/templates/types/multiagent/fastapi/app/agents/planner.py @@ -129,7 +129,9 @@ class StructuredPlannerAgent(Workflow): ) # bubble all events while running the executor to the planner async for event in handler.stream_events(): - ctx.write_event_to_stream(event) + # Don't write the StopEvent from sub task to the stream + if type(event) is not StopEvent: + ctx.write_event_to_stream(event) result: AgentRunResult = await handler if self._verbose: print("=== Done executing sub task ===\n") diff --git a/templates/types/multiagent/fastapi/app/examples/workflow.py b/templates/types/multiagent/fastapi/app/examples/workflow.py index ba62644319419feaa113ae103bf1111e9089d65b..c92f96ab9c92dbce65852f2f72920b6b7f35597d 100644 --- a/templates/types/multiagent/fastapi/app/examples/workflow.py +++ b/templates/types/multiagent/fastapi/app/examples/workflow.py @@ -133,5 +133,7 @@ Review: handler = agent.run(input=input, streaming=streaming) # bubble all events while running the executor to the planner async for event in handler.stream_events(): - ctx.write_event_to_stream(event) + # Don't write the StopEvent from sub task to the stream + if type(event) is not StopEvent: + ctx.write_event_to_stream(event) return await handler