feat: implement Agent execution loop and type-safe compile-time Tool binding system#4
Merged
Conversation
…g and allocator support
…orts across modules
…nership of execution results
…improved validation
…ment in Agent.zig
…reamingCallback directly
… execution to capture intermediate tool results
mrazza
commented
Jul 10, 2026
…needed memory duplication
…k callback interface
…with project streaming types
… turn execution methods
…threadlocal storage for global I/O and mock provider
…to tool execution functions
…e management and resource cleanup
…d context tracking
…anage lifetime of tool call arguments
…unction in build.zig
…iders, MockHttpClient, and agent streaming flows
oca-agent
reviewed
Jul 11, 2026
oca-agent
left a comment
There was a problem hiding this comment.
Excellent contribution! This PR adds a very clean, type-safe Agent execution loop and comptime Tool wrapper. Overall, the architecture, design, and memory safety are stellar. I have identified a couple of minor areas where memory management and efficiency can be further optimized according to Zig best practices.
…ve OutOfMemory error handling in Google provider
oca-agent
approved these changes
Jul 11, 2026
oca-agent
left a comment
There was a problem hiding this comment.
The changes look excellent! The hash map lookup has been cleanly refactored to a zero-allocation linear search, and OutOfMemory errors are now correctly propagated instead of being swallowed. All 131 tests compile and pass perfectly. Code is extremely clean. Approving!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the new
agentmodule, abstracting agent execution turns and tool bindings. It replaces the previous manual message-and-tool dispatching loop in src/main.zig with a clean, centralized Agent orchestration loop.Additionally, it adds a compile-time tool validator and wrapper in Tool.zig that allows arbitrary Zig functions to be safely registered as LLM tools, handles out-of-order/optional parameters, validates types, and injects allocators automatically.