Skip to content

agentic_loop: derive tool calls from response_object.output for terminal-event reconciliation #277

Description

@leseb

Context

Issue #26 comment #2 notes that when stream_events lands, state.tool_calls can be stale relative to response_object after a terminal event (response.completed). The terminal event overwrites response_object with the authoritative payload, but does not rebuild state.tool_calls — so tool_calls reflects incrementally accumulated deltas while response_object.output reflects the terminal truth.

Currently tool_dispatch reads exclusively from state.tool_calls via std::mem::take(&mut state.tool_calls).

Proposed fix

Derive tool calls from response_object["output"] at dispatch time (option 1 from the comment — single source of truth). Fall back to tool_calls when response_object has no output (backward compat for pre-stream_events paths).

Blocked by

  • Filter 6: stream_events #25 (stream_events) — until terminal events populate response_object, the fallback path is the only one exercised

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Task.

    Projects

    Status
    Next

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions