Add tool calling and API format support to flatagents#7
Draft
memgrafter wants to merge 8 commits into
Draft
Conversation
- Add tool calling support: tools, tool_choice, parallel_tool_calls - Add response_format with json_schema type for structured outputs - Add missing model parameters: repetition_penalty, stop, logit_bias - Update ModelConfig, LLMOptions, and runtime spec with new fields - Sync schema files across all SDK locations https://claude.ai/code/session_01GaVWKmhxt2ncfpUtNHvNc4
Implements tool_loop feature for agent states:
- Add tool_loop config (boolean or ToolLoopConfig with max_rounds)
- Add tools/tool_choice fields to StateDefinition
- Add on_tool_call hook for executing tool calls
- Implement tool loop execution in Python SDK flatmachine.py
- Update FlatAgent.call() to accept _tools and _tool_choice params
Example usage:
states:
research:
agent: researcher
tool_loop:
max_rounds: 10
tools:
- type: function
function:
name: search
parameters: { type: object, properties: { query: { type: string } } }
input:
question: "{{ context.question }}"
Hooks must implement on_tool_call(tool_name, arguments, context) to
execute tools and return results.
https://claude.ai/code/session_01GaVWKmhxt2ncfpUtNHvNc4
Tests use a real HTTP stub server (aiohttp) - no mocks: - test_single_tool_call_then_response: Basic single tool call flow - test_multiple_tool_calls_in_sequence: Sequential tool calls - test_tool_loop_max_rounds_limit: Verify max_rounds is respected - test_no_tool_calls_immediate_response: LLM responds without tools - test_tool_call_with_error_handling: Tool errors are handled gracefully - test_tool_results_passed_back_to_llm: Verify tool results in messages - test_tool_loop_disabled_no_tools: No tools when feature disabled - test_tool_with_dynamic_result: Tools with dynamic results Also adds dev dependencies (pytest, pytest-asyncio, aiohttp) to pyproject.toml. https://claude.ai/code/session_01GaVWKmhxt2ncfpUtNHvNc4
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.
https://claude.ai/code/session_01GaVWKmhxt2ncfpUtNHvNc4