Skip to content

feat(tools): ToolExecutor registry, mock, and native tools (issue #18)#52

Merged
leo-aa88 merged 1 commit into
mainfrom
issue/18-tool-executor
Apr 11, 2026
Merged

feat(tools): ToolExecutor registry, mock, and native tools (issue #18)#52
leo-aa88 merged 1 commit into
mainfrom
issue/18-tool-executor

Conversation

@leo-aa88
Copy link
Copy Markdown
Member

Summary

Implements the ToolExecutor boundary from design doc §12.2 G with a registry that parses workflow uses strings (tool.<name>.<operation>), a mock executor for tests, and native built-ins (echo, identity). Responses follow §13.2 (output map + meta with durationMs / costUsd placeholders).

API

Types (types.go)

  • ToolExecutorCall(ctx, ToolCallRequest) (ToolCallResponse, error)
  • ToolCallRequestUses, With map[string]any
  • ToolCallResponseOutput map[string]any, Meta ToolCallMeta

Registry (registry.go)

  • ParseUses("tool.github.pull_request.get")github, pull_request.get
  • NewRegistry(graph) — looks up graph.Tools[name] and routes by ToolSpec.Type:
    • nativeinternal/tools/native registry (echo, identity)
    • mock → optional Registry.Mock ToolExecutor, else canned JSON {"message":"mock",...}
  • Unsupported types return a clear error (MCP/HTTP deferred per issue scope)

Native (native/registry.go)

  • echo — returns {"echo": <shallow copy of with>}
  • identity — returns {"value": with["value"], "ok": <present>}

Errors (errors.go)

  • *UnknownOperationErrorTool, Operation fields; returned when a native tool does not implement the operation (errors.As-friendly)

Mock (mock.go)

  • MockExecutor — fixed Resp / Err or custom Fn

Normalize (normalize.go)

  • Ensures non-nil Output; fills DurationMs from wall clock if still zero

Tests

  • Native echo succeedstool.demo.echo with payload round-trips under output.echo
  • Unknown operationtool.demo.no_such_operrors.As(..., *UnknownOperationError) with correct tool/operation
  • ParseUses design-doc style path; MockExecutor isolation

Verification

  • make fmt (go fmt ./...)
  • make test (go test ./... -race)
  • make vet

Closes #18

Made with Cursor

Add ToolExecutor, ToolCallRequest/Response (output + meta §13.2), ParseUses
for tool.<name>.<operation>, Registry dispatching native and mock tool
types, MockExecutor, and native echo/identity operations.

Unknown native operations return *UnknownOperationError for structured
handling (issue #18).

Made-with: Cursor
@leo-aa88 leo-aa88 merged commit 2b03c9f into main Apr 11, 2026
4 checks passed
@leo-aa88 leo-aa88 deleted the issue/18-tool-executor branch April 11, 2026 21:44
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.

[MVP] ToolExecutor registry, mock, and native tools (internal/tools)

1 participant