feat: implement call operation for tool invocation (fixes #40)#41
Merged
andreasronge merged 1 commit intomainfrom Dec 2, 2025
Merged
feat: implement call operation for tool invocation (fixes #40)#41andreasronge merged 1 commit intomainfrom
andreasronge merged 1 commit intomainfrom
Conversation
Add call operation to allow PTC programs to invoke registered tool functions. This is the core feature of Phase 4 (Tool Integration), enabling LLMs to generate programs that call user-defined tools and process their results. Changes: - Add validation clause for "call" operation in validator.ex - Validates required "tool" field - Validates optional "args" field (must be map if provided) - Add eval function for "call" operation in operations.ex - Invokes registered tool by name with provided arguments - Defaults to empty map for args if not provided - Handles missing tool errors - Handles tool error returns - Catches and converts tool exceptions - Uses is_function(tool_fn, 1) for arity validation - Add comprehensive test suite covering: - Unit tests for all acceptance criteria - Tool argument handling - Error cases (missing tool, error tuple, exceptions, wrong arity) - Validation errors - E2E test with pipe integration - E2E test with let binding All tests pass (236 tests, 0 failures). 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
12 tasks
Contributor
PR Review: feat: implement call operation for tool invocationSummaryThis PR implements the What's Good
Issues (Must Fix)None identified. The implementation is complete and consistent. Suggestions (Optional)
SecurityNo concerns. The implementation:
VerdictApprove - The implementation is clean, well-tested, and follows established patterns. All acceptance criteria from issue #40 are met:
|
5 tasks
Owner
Author
Auto-Triage SummaryDecisions Made
Status
Next StepsNo fixes needed. The PR is approved and ready to merge. All acceptance criteria from issue #40 are met with comprehensive test coverage. |
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.
Summary
Implements the
calloperation for Phase 4 (Tool Integration), enabling PTC programs to invoke registered tool functions with provided arguments and handle their results.What Changed
Validator (
lib/ptc_runner/validator.ex)Operations (
lib/ptc_runner/operations.ex)%{}if not provided){:error, reason}: propagates as execution erroris_function(tool_fn, 1)Tests (
test/ptc_runner_test.exs)Test Results
All 236 tests pass (including 3 doctests, 13 new tests for call operation).
Checklist
literalandletoperationsletand other operationsis_function(tool_fn, 1))Fixes #40
🤖 Generated with Claude Code