Skip to content

feat: add built-in shell tool and migrate interfaces to intrusive VTables - #6

Merged
mrazza merged 11 commits into
mainfrom
feat/shell-tool
Oct 24, 2026
Merged

mrazza merged 11 commits into
mainfrom
feat/shell-tool

Conversation

@mrazza

@mrazza mrazza commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Built-in Shell Execution Tool (src/agent/tool/shell.zig):
    • Adds agent.Tool.BuiltIn.Shell supporting POSIX shells (sh, bash, zsh), Windows cmd, and PowerShell (powershell, pwsh), plus Shell.default.
    • Executes commands with configurable timeouts, captures stdout, stderr, exit codes, and signal termination messages as structured JSON, and truncates outputs exceeding 2,000 lines into temporary overflow files.
    • Registers Shell.default in src/main.zig and updates Todo/system prompt instructions.
  • Intrusive VTable (@fieldParentPtr) Migration:
    • Migrates agent.Tool, llm.Provider, llm.types.ListModelsResult, llm.types.StepResult, and llm.types.StepContinuation from ptr: *anyopaque / ctx: ?*anyopaque fat pointers to the intrusive VTable (@fieldParentPtr) pattern matching Zig 0.16 (std.Io.Reader/Writer).
    • Replaces Tool.init / Tool.initWithContext with Tool.initStateless (for stateless function tools) and Tool.wrapExecute + Tool.VTable (for stateful tools embedding tool: Tool), and updates SessionConfig.tools to []const *const Tool.
    • Moves BlockingTool to src/agent/testing/BlockingTool.zig as a non-generic struct.

Testing

  • zig build test --summary all (all 227 tests pass)
  • zig build

@mrazza mrazza self-assigned this Oct 19, 2026

@oca-agent oca-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review

Detailed review of PR #6 covering the built-in shell tool and intrusive VTable migration.

Comment thread src/agent/tool/shell.zig Outdated
Comment thread src/agent/tool/shell.zig Outdated
Comment thread src/agent/tool/shell.zig Outdated
Comment thread src/agent/testing/BlockingTool.zig Outdated
Comment thread src/agent/tool/shell.zig Outdated

@oca-agent oca-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! All review comments have been cleanly resolved in commit 1966e08:

  • Added explicit cancellation support to and propagated across , , and .
  • Replaced the hardcoded Windows temp path with dynamic lookup () checking , , and before fallback.
  • Properly propagated and in .
  • Removed dead code in .
  • Switched to POSIX octal escapes in the non-UTF8 sanitization test, resolving CI test failures on dash/Ubuntu.

All 232 tests pass locally and in CI.

@oca-agent oca-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! All review comments have been cleanly resolved in commit 1966e08:

  • Added explicit cancellation support to Tool.CallError (std.Io.Cancelable) and cleanly propagated error.Canceled across BlockingTool, Shell, and Session.executeTurnInternal.
  • Replaced the hardcoded Windows temp path with dynamic lookup (getTempDirAlloc) checking TEMP, TMP, and %USERPROFILE%\AppData\Local\Temp with fallback to C:\Windows\Temp.
  • Explicitly propagated error.OutOfMemory and error.Canceled in processStream.
  • Removed dead code in findCutoff.
  • Switched printf to POSIX octal escapes in the non-UTF8 sanitization test, resolving the CI failure on Ubuntu / dash.

All 232 tests pass locally and in GitHub Actions CI.

@mrazza
mrazza merged commit 08c2d7e into main Oct 24, 2026
2 checks passed
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.

2 participants