Skip to content

fix(chat): the capped final pass can stream a stray tool call and skips its hooks #20720

Open

Description

@mrveiss

Problem

Found in review on the merge train (PR #20713), in autobot-backend/chat_workflow/graph.py:

  1. force_final_answer drops the final pass's tool calls (_unused_calls), but _run_llm_iteration_plan has already streamed the raw text. If the model ignores FINAL_ANSWER_INSTRUCTION, the user sees and the transcript stores a raw TOOL_CALL block.
  2. The final pass skips the execute and complete hooks and agent.step.* events that generate_response emits, so audit logs and the reasoning trace miss it.

Acceptance criteria

  • A final pass that emits a TOOL_CALL never streams or stores it; the apology message is used when no answer remains. Tested.
  • The final pass emits the same hooks and step events as a normal pass. Tested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendbugSomething isn't workingphase:M1.8Knowledge base: upload, web sources and chat retrieval work end to end

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions