Skip to content

Conversation

@DouweM
Copy link
Collaborator

@DouweM DouweM commented Jul 25, 2025

Fixes #2311

Refines the retry logic to move retry count management from _call_tool to for_run_step method. This ensures retry counts are scoped per tool name per run step rather than per individual failure.

Changes

  • Added failed_calls: set[str] field to track tools that failed in current run step
  • Modified _call_tool to add failed tool names to failed_calls instead of incrementing retry count
  • Updated for_run_step to build new retry dict with only failed tool names and their updated counts
  • Removed success clearing logic from _call_tool since it's now handled in for_run_step

Generated with Claude Code

Move retry count management from _call_tool to for_run_step method.
Build new retry dict with only failed_calls keys inheriting ctx.retries values + 1.
This ensures retry counts are scoped per tool name per run step rather than per individual failure.

Co-authored-by: Douwe Maan <DouweM@users.noreply.github.com>
@DouweM DouweM self-assigned this Jul 25, 2025
@DouweM
Copy link
Collaborator Author

DouweM commented Jul 25, 2025

@claude Rename failed_calls to failed_tools, updated_retries to retries, and add tests

@claude
Copy link
Contributor

claude bot commented Jul 25, 2025

Claude finished @DouweM's task —— View job


Todo List

  • Read the current code to understand variable names and retry logic
  • Rename failed_calls to failed_tools
  • Rename updated_retries to retries
  • Add tests for the retry logic
  • Commit and push changes

✅ Changes completed successfully!

Variable renames in pydantic_ai_slim/pydantic_ai/_tool_manager.py:

  • failed_callsfailed_tools (field, initialization, and all references)
  • updated_retriesretries (variable and usage)

Added comprehensive tests in tests/test_toolsets.py:

  • test_tool_manager_retry_logic() - tests the new retry logic with failed_tools and for_run_step method
  • test_tool_manager_multiple_failed_tools() - tests multiple tools failing in same run step
  • Tests verify that retry counts are properly scoped per tool name per run step

Note: I wasn't able to run make lint and make typecheck due to permission restrictions. You may want to run these commands locally to ensure code quality standards are met.

The changes have been committed and pushed to the PR branch.

claude bot and others added 2 commits July 25, 2025 20:10
- Rename failed_calls field to failed_tools for better clarity
- Rename updated_retries variable to retries for consistency
- Add comprehensive tests for retry logic including:
  - Test for basic retry logic with failed_tools and for_run_step
  - Test for multiple failed tools in same run step
  - Verify retry counts are properly scoped per tool name per run step

Co-authored-by: Douwe Maan <DouweM@users.noreply.github.com>
@DouweM
Copy link
Collaborator Author

DouweM commented Jul 25, 2025

@claude You're now able to run make install, make test, and make lint

@claude
Copy link
Contributor

claude bot commented Jul 25, 2025

Claude finished @DouweM's task —— View job


Todo List

  • Install dependencies with make install
  • Run tests with make test
  • Run linting with make lint
  • Report results

❌ Unable to run validation commands

I attempted to run make install but encountered missing system dependencies:

/bin/sh: 1: uv: not found
/bin/sh: 1: pre-commit: not found
✖ Error: deno is not installed, but is needed for mcp-run-python

The environment is missing required tools:

  • uv (Python package manager)
  • pre-commit (Git hook framework)
  • deno (JavaScript/TypeScript runtime)

✅ Previous changes completed successfully

The core task was already completed in the previous interaction:

Variable renames in pydantic_ai_slim/pydantic_ai/_tool_manager.py:

  • failed_callsfailed_tools (field, initialization, and all references)
  • updated_retriesretries (variable and usage)

Added comprehensive tests in tests/test_toolsets.py:

  • test_tool_manager_retry_logic() - tests the new retry logic with failed_tools and for_run_step method
  • test_tool_manager_multiple_failed_tools() - tests multiple tools failing in same run step

The changes have been committed and pushed to the PR branch. The code validation will need to be run in an environment with the required system dependencies installed.

@github-actions
Copy link

github-actions bot commented Jul 25, 2025

Docs Preview

commit: 7325617
Preview URL: https://1296ac04-pydantic-ai-previews.pydantic.workers.dev

DouweM added 2 commits July 28, 2025 23:09
# Conflicts:
#	pydantic_ai_slim/pydantic_ai/_tool_manager.py
@DouweM DouweM enabled auto-merge (squash) July 28, 2025 23:21
@DouweM DouweM merged commit ab92e67 into main Jul 28, 2025
16 checks passed
@DouweM DouweM deleted the claude/issue-2311-20250725-2000 branch July 28, 2025 23:23
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.

Max tool retry is inconsistent when used with parallel tool calling

2 participants