Skip to content

feat(core): dual-mode agent loop for native tool_use #258

@bug-ops

Description

@bug-ops

Problem

Agent loop only supports text-based tool extraction. Need to branch based on provider capability.

Solution

In process_response():

  • If provider.supports_tool_use(): use chat_with_tools(), handle ChatResponse::ToolUse
  • Else: use existing text extraction path (bash blocks)
  • Tool execution reuses same ToolExecutor pipeline
  • ToolResult fed back as ToolResult MessagePart

Acceptance Criteria

  • Agent detects provider tool_use support
  • Native path: structured tool calls → execute → tool result → next iteration
  • Text path: unchanged behavior
  • Both paths respect PermissionPolicy
  • Both paths respect max_tool_iterations and doom-loop detection

Part of #253 (M20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions