Skip to content

feat(agent): implement tool-use orchestration loop - #103

Merged
Svagtlys merged 13 commits into
developfrom
feature/tool-use-orchestration-loop
Sep 26, 2026
Merged

Svagtlys merged 13 commits into
developfrom
feature/tool-use-orchestration-loop

Conversation

@Svagtlys

@Svagtlys Svagtlys commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Closes #79

Description

Implements the reason → act → observe tool-use orchestration loop: detect model tool calls, execute them against MCP servers, feed results back as provider-native tool messages, and re-invoke for final synthesis. Library-only primitive — no routes/lifespan wiring (Integration & Testing #1 composes it).

Implementation

  • octave.inference types: ToolCall(id, name, arguments: str); Message gains tool_calls/tool_call_id/name and "tool" role; CompletionResult.tool_calls (additive, OpenAI-dialect)
  • OpenAIAdapter: parses choice.message.tool_calls from completion responses; serializes tool-carrying messages to provider payloads with exclude_none (strict local engines reject null tool keys) and the function-call envelope
  • octave.tools.errors: ToolError base introduced; ToolTranslationError re-based under it (backward-compatible)
  • octave.agent (new package): composition layer and future Agent Manager home
    • ToolLoop — round mechanics, provider-invariant transcript ordering, max_tool_rounds limit raising ToolLoopLimitError with partial transcript; two-tier error split (Tier-1 model-correctable → Error: -prefixed tool messages; Tier-2 fatal → raise)
    • ToolExecutor Protocol — execution seam; implementations never raise for tool-level failures
    • McpToolExecutor — wraps ToolRegistry; joins text blocks, (no output) sentinel, McpError → ToolOutcome(is_error=True) conversion
    • SDK quarantine: AST guard (tests/agent/test_package.py) proves no openai/mcp imports; only mcp_executor.py touches octave.mcp
  • docs/ARCHITECTURE.md: octave.agent section + MCP Connector schema-translation status updated

References

  • Design doc: .agents/specs/2026-09-25-tool-use-orchestration-loop-design.md
  • Implementation plan: .agents/specs/2026-09-25-tool-use-orchestration-loop.md

Checklist

  • Tests passing (317/317)
  • Lint clean (ruff check src tests)
  • Types clean (mypy src, 54 files)
  • Frontend builds: not applicable (no frontend changes)

Notes for reviewer

  • Plan deviation: the plan's loop-limit test asserted a 5-message partial transcript, contradicting spec Testing item 10 (transcript must end on the unfulfilled assistant tool_calls message, N+1 completions). The test was corrected to match the spec, which the implementation satisfies.
  • The style: commit swept in plans/2026-09-25-issue-concurrent-tool-execution.md (deferred concurrent-execution issue draft referenced by the design doc).

@Svagtlys Svagtlys added this to the 1.0 — Initial Release milestone Sep 25, 2026
@Svagtlys Svagtlys added enhancement New feature or request area:agent Agent Manager labels Sep 25, 2026
@Svagtlys Svagtlys self-assigned this Sep 25, 2026
@Svagtlys
Svagtlys marked this pull request as ready for review September 26, 2026 08:00
@Svagtlys
Svagtlys merged commit 4b52c97 into develop Sep 26, 2026
3 checks passed
@Svagtlys
Svagtlys deleted the feature/tool-use-orchestration-loop branch September 26, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent Manager enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(agent): implement tool-use orchestration loop

1 participant