Skip to content

perf: collapse ReActReasoning into a single-turn completion #299

Description

@abikooo

Problem

ReActReasoning currently triggers two separate LLM completions per agent step:

A "planning" pass to generate a thought.

An "execution" pass to translate that thought into a tool call.

This "Reasoning Tax" doubles latency and increases token costs significantly for every simulation step.

Proposed Optimization

Refactor aplan() to use a single agenerate call with native tool_choice="auto". This allows the model to provide reasoning in the message content and the action in the tool calls simultaneously.

Verification Results

I have verified this optimization with a benchmark script (tests/verify_tax.py):

Current: 2 LLM calls per step.

Refactored: 1 LLM call per step.

Latency Reduction: ~50%.

I have a fix ready and will submit a PR immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions