Skip to content

feat(models): run_tool_loop shared turn-loop primitive#26

Draft
pradeepvrd wants to merge 1 commit into
integration/devops-bench-stage1from
submit/1-models-loop
Draft

feat(models): run_tool_loop shared turn-loop primitive#26
pradeepvrd wants to merge 1 commit into
integration/devops-bench-stage1from
submit/1-models-loop

Conversation

@pradeepvrd

@pradeepvrd pradeepvrd commented Jun 20, 2026

Copy link
Copy Markdown
Owner

The agent turn-loop used to be inline in pkg/agents/runner/api/api.py (the run_api_agent loop, coupled to MCP/skill tools); this extracts it into a shared, provider-agnostic devops_bench/models/loop.pyrun_tool_loop over a neutral tool-dispatch seam — reused by the API agent and the chaos agent. No new deps.

Behavior changes

  • An explicit max_turns cap is enforced (and logged when hit) instead of looping until the model stops on its own.
  • Tool-dispatch errors propagate to the caller through the dispatcher seam instead of being swallowed and appended as error strings inside the loop.
  • Returns a typed LoopResult (response, contents, final_text, latency, tools_used) instead of a dict; latency uses time.monotonic().

Bugs fixed

  • The previous loop had no turn cap and could run unbounded against a misbehaving model.
  • The model's final summary was dropped when a tool call landed on the last turn; the text is now captured every turn.

The agent turn-loop used to be inline in `pkg/agents/runner/api/api.py` (the `run_api_agent` loop, coupled to MCP/skill tools); this extracts it into a shared, provider-agnostic `devops_bench/models/loop.py` — `run_tool_loop` over a neutral tool-dispatch seam — reused by the API agent and the chaos agent. No new deps.

**Behavior changes**
- An explicit `max_turns` cap is enforced (and logged when hit) instead of looping until the model stops on its own.
- Tool-dispatch errors propagate to the caller through the dispatcher seam instead of being swallowed and appended as error strings inside the loop.
- Returns a typed `LoopResult` (response, contents, final_text, latency, tools_used) instead of a dict; latency uses `time.monotonic()`.

**Bugs fixed**
- The previous loop had no turn cap and could run unbounded against a misbehaving model.
- The model's final summary was dropped when a tool call landed on the last turn; the text is now captured every turn.
@pradeepvrd pradeepvrd force-pushed the submit/1-models-loop branch from 2827366 to 49f0968 Compare June 23, 2026 17:59
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