Skip to content

fix: use agent structured output in workflows#22172

Open
fengjikui wants to merge 1 commit into
run-llama:mainfrom
fengjikui:fix/agent-workflow-agent-structured-output
Open

fix: use agent structured output in workflows#22172
fengjikui wants to merge 1 commit into
run-llama:mainfrom
fengjikui:fix/agent-workflow-agent-structured-output

Conversation

@fengjikui

Copy link
Copy Markdown

Summary

Root cause

AgentWorkflow finalization called agent.finalize(...) but then only consulted self.structured_output_fn and self.output_cls. As a result, structured output configured on a FunctionAgent worked with agent.run(...) but was ignored when the same agent ran inside an AgentWorkflow.

Test plan

  • Reproduced before the fix: test_agentworkflow_uses_agent_structured_output_fn failed because no AgentStreamStructuredOutput event was emitted.
  • uv run --frozen --project llama-index-core pytest llama-index-core/tests/agent/workflow/test_agent_with_structured_output.py::test_agentworkflow_uses_agent_structured_output_fn -q
  • uv run --frozen --project llama-index-core pytest llama-index-core/tests/agent/workflow/test_agent_with_structured_output.py -q
  • uv run --frozen --project llama-index-core pytest llama-index-core/tests/agent/workflow/test_multi_agent_workflow.py -q
  • uv run --frozen --project llama-index-core ruff format --check llama-index-core/llama_index/core/agent/workflow/multi_agent_workflow.py llama-index-core/tests/agent/workflow/test_agent_with_structured_output.py
  • uv run --frozen --project llama-index-core ruff check llama-index-core/llama_index/core/agent/workflow/multi_agent_workflow.py llama-index-core/tests/agent/workflow/test_agent_with_structured_output.py

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: FunctionAgent.structured_output_fn is ignored when executed via AgentWorkflow

1 participant