Skip to content

Add tool calling and API format support to flatagents#7

Draft
memgrafter wants to merge 8 commits into
mainfrom
claude/add-tool-calling-flatagents-NnD5z
Draft

Add tool calling and API format support to flatagents#7
memgrafter wants to merge 8 commits into
mainfrom
claude/add-tool-calling-flatagents-NnD5z

Conversation

@memgrafter

Copy link
Copy Markdown
Owner
  • 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

memgrafter and others added 8 commits January 31, 2026 14:02
- 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
@memgrafter memgrafter marked this pull request as draft March 4, 2026 20:20
@memgrafter memgrafter added the invalid This doesn't seem right label Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants