Skip to content

refactor(ai): collapse ReAct into a single reason-act loop - #1533

Open
larry-zy wants to merge 1 commit into
apache:aifrom
larry-zy:refactor/react-single-loop
Open

refactor(ai): collapse ReAct into a single reason-act loop#1533
larry-zy wants to merge 1 commit into
apache:aifrom
larry-zy:refactor/react-single-loop

Conversation

@larry-zy

Copy link
Copy Markdown

What

Collapse the two-stage reasonAct / observe ReAct pipeline into one bounded reason-act loop.

Each iteration is a single model call that either requests tools (whose results are fed back as context for the next iteration) or answers directly — a tool-free response is the final answer, so no separate observe reasoning step is needed to decide when to stop. The last allowed iteration drops the tools and forces a final answer, so the loop always terminates with a real reply rather than exhausting its budget in silence.

Changes

  • Remove the orchestrator / state / step / runLoop scaffolding and the fallback handler package; drive the loop directly from run().
  • Flatten AgentSpec to a single prompt_file; derive the tool-less answer prompt from the same system prompt plus an answer directive.
  • Drop the agentObserve.txt prompt; keep agentReasonAct.txt.
  • Update agent.schema.json, the config loader test, the e2e test and fixtures to the flat single-stage config.

Scope

Backend only — all changes are under ai/. No frontend (ui-vue3/) changes.

Verification

  • go build ./... passes.
  • ReAct unit / step / flow tests updated to the single-loop shape.

Fold the two-stage reasonAct/observe pipeline into one bounded
reason-act loop: each iteration is a single model call that either
requests tools (results fed back as context) or answers directly — a
tool-free response IS the final answer, so no separate observe stage is
needed to decide when to stop. The last iteration drops tools and forces
a final answer so the loop always terminates.

- Remove the orchestrator/state/step/runLoop scaffolding and the fallback
  handler package; drive the loop directly from run().
- Flatten AgentSpec to a single prompt_file; derive the tool-less answer
  prompt from the same system prompt plus an answer directive.
- Drop the agentObserve.txt prompt; keep agentReasonAct.txt.
- Update agent.schema.json, config loader test, e2e test and fixtures to
  the flat single-stage config.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant