feat: generate final answer when max_agent_steps reached#10011
feat: generate final answer when max_agent_steps reached#10011dcondrey wants to merge 4 commits intodeepset-ai:mainfrom
Conversation
|
@dcondrey is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
This fixes a contract break in Agent.run() when max_agent_steps is hit on a tool call. Previously the agent could exit with a raw ToolResult as last_message. With final_answer_on_max_steps=True (default), the agent makes one extra, tool-disabled LLM call only in that case to produce a proper final ChatMessage. Setting it to False preserves the old behavior. Normal runs and step limits are otherwise unchanged. |
|
@dcondrey thanks for working on this so quickly but we are still discussing internally if this is a pattern we we want to support. For example, an alternative is to pipe the output of the Agent to other downstream components like a ChatGenerator component to generate a final answer instead of adding this complexity inside of the Agent component. |
Related Issues
Proposed Changes:
Previously, if
step_count≥max_agent_stepsandlast_msg∈ToolResult, output = ToolResult (no final text).Now, if
step_count≥max_agent_stepsandlast_msg∈ ToolResult, optionally perform 1 extra LLM call →final_text_answer.How did you test it?
test/components/agents/test_agent.pyNotes for the reviewer
Checklist
✓ I have read the contributors guidelines and the code of conduct
✓ I added unit tests and updated the docstrings
✓ I've used one of the conventional commit types for my PR title:
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.✓ I documented my code
✓✓ I ran pre-commit hooks and fixed any issue