Skip to content

fix: self-repair and actionable feedback on unknown tool calls#3323

Merged
praisonai-triage-agent[bot] merged 2 commits into
mainfrom
claude/issue-3309-20260723-1025
Jul 23, 2026
Merged

fix: self-repair and actionable feedback on unknown tool calls#3323
praisonai-triage-agent[bot] merged 2 commits into
mainfrom
claude/issue-3309-20260723-1025

Conversation

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor

Fixes #3309

Summary

Adds a small, zero-overhead resilience layer to the core agent tool-dispatch path (agent/tool_execution.py) so an unresolvable tool call no longer collapses to a terse Tool 'X' is not callable.

At the existing fall-through point in _execute_tool_impl:

  1. Self-repair — build a case/separator-normalised index of the agent's active tools and re-match (e.g. WebSearch / web-searchweb_search); execute if a unique match exists.
  2. Actionable feedback — otherwise return a model-readable error naming the nearest valid tool (fuzzy difflib) and listing the currently available tools. This message is what already gets fed back to the model as the tool result, so it can self-correct instead of repeating the mistake.
  3. Bind failures — on an argument-binding (TypeError/ValueError) exception, echo the tool's required/optional parameter names so the model can retry correctly.

Stays on the existing dispatch path so hooks, tracing, retry and loop-detection keep firing. No new public API, no new Agent params, and zero cost on the happy path.

Changes

  • src/praisonai-agents/praisonaiagents/agent/tool_execution.py — self-repair re-match + corrective error + _get_tool_display_name / _available_active_tool_names / _normalise_tool_key / _tool_parameter_hint helpers.
  • src/praisonai-agents/tests/unit/tools/test_tool_resolution_repair.py — 6 unit tests (mis-cased auto-resolve, separator drift, unknown-name inventory, nearest suggestion, bind-schema echo, active-tool enumeration).

Test plan

  • pytest tests/unit/tools/test_tool_resolution_repair.py — 6 passed
  • pytest tests/unit/tools/test_tool_resolver.py test_tool_search.py — 33 passed, no regressions

Generated with Claude Code

@MervinPraison

Copy link
Copy Markdown
Owner

@coderabbitai review

@MervinPraison

Copy link
Copy Markdown
Owner

/review

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@MervinPraison MervinPraison added pipeline/blocked:ci Blocked: CI not green on HEAD pipeline/blocked:no-final Blocked: no FINAL @claude trigger yet pipeline/final-claude-pending Reviews done; waiting for FINAL @claude labels Jul 23, 2026
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR refines tool-call repair feedback after earlier review:

  • Distinguishes argument-binding failures from exceptions raised inside successfully bound tools.
  • Resolves class-based and BaseTool invocation targets before checking signature binding.
  • Adds coverage ensuring runtime validation errors do not receive parameter-schema hints.

Confidence Score: 4/5

The PR is not yet safe to merge because binding failures from @tool-decorated tools still omit the actionable parameter schema.

FunctionTool instances expose a generic run(**kwargs) method, so the new hint path detects no required or optional parameters even when the wrapped function failed argument binding.

src/praisonai-agents/praisonaiagents/agent/tool_execution.py

Important Files Changed

Filename Overview
src/praisonai-agents/praisonaiagents/agent/tool_execution.py Refines binding-error classification, but decorated FunctionTool binding failures still lose parameter hints because their generic wrapper signature is inspected.
src/praisonai-agents/tests/unit/tools/test_tool_resolution_repair.py Adds focused regression coverage for runtime ValueError classification and active-tool enumeration.

Reviews (3): Last reviewed commit: "fix: only echo tool parameter hint on ge..." | Re-trigger Greptile

Comment thread src/praisonai-agents/praisonaiagents/agent/tool_execution.py Outdated
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@MervinPraison, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ce5b60bc-97d4-405f-af9c-cf57ac17219e

📥 Commits

Reviewing files that changed from the base of the PR and between 7494bba and e629cf5.

📒 Files selected for processing (2)
  • src/praisonai-agents/praisonaiagents/agent/tool_execution.py
  • src/praisonai-agents/tests/unit/tools/test_tool_resolution_repair.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-3309-20260723-1025

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MervinPraison

Copy link
Copy Markdown
Owner

@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding.

Phase 1: Review per AGENTS.md

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions
  4. SDK value: review in depth whether the change genuinely adds value to the SDK — never add features for the sake of adding them. It must strengthen the SDK (simpler, more user-friendly, robust, world-class, secure). If it does not clearly add value, request changes or recommend rejecting/closing rather than merging scope creep
  5. Do not bloat the Agent class with additional params — only if absolutely required; we already support many params.
  6. Repo routing: agent-callable tools → PraisonAI-Tools; lifecycle plugins → PraisonAI-Plugins; optional sandbox backends → PraisonAI-Plugins (praisonai.sandbox entry point) — request changes if wrongly added to praisonaiagents/

Phase 2: FIX Valid Issues
7. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
8. Also independently identify and fix any gaps or issues you find in the changed code — do not rely only on prior reviewer feedback
9. Push all code fixes directly to THIS branch (do NOT create a new PR)
10. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
11. If all issues are resolved, approve the PR / close the Issue
12. If blocking issues remain, request changes / leave clear action items

@MervinPraison MervinPraison added pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI pipeline/blocked:cooldown Blocked: post-push or @claude cooldown and removed pipeline/final-claude-pending Reviews done; waiting for FINAL @claude pipeline/blocked:no-final Blocked: no FINAL @claude trigger yet labels Jul 23, 2026
@praisonai-triage-agent

praisonai-triage-agent Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Claude finished @MervinPraison's task —— View job


Final Architecture Review — PR #3323

  • Read AGENTS.md + CLAUDE.md guidelines
  • Read changed files (tool_execution.py, tests)
  • Phase 1: Architecture review
  • Phase 2: Evaluate reviewer feedback
  • Phase 2: Implement fix for Greptile finding
  • Phase 3: Test + final verdict

Phase 1 — Architecture (per AGENTS.md)

Check Result
Protocol-driven / core-vs-wrapper ✅ Stays on the existing core dispatch path in praisonaiagents/agent/tool_execution.py; no heavy impl added
Backward compatible ✅ No new public API, no new Agent params, no __init__.py exports; happy path unchanged
Performance ✅ Zero cost on success — self-repair/feedback only run at the existing fall-through after a tool is unresolved or raises
SDK value ✅ Genuine: converts dead-end Tool 'X' is not callable into self-correcting, model-readable feedback (self-repair + nearest-match + schema echo)
Agent-class bloat ✅ No params added
Repo routing ✅ Correctly in core (dispatch resilience, not an agent-callable tool or lifecycle plugin)

Phase 2 — Fix implemented (Greptile finding, valid)

The except (TypeError, ValueError) at the invocation site wrapped the actual tool call, so a tool raising TypeError/ValueError inside its own logic (domain validation) got a misleading parameters — hint, misdirecting the model to alter valid arguments.

Fix (b3250ec):

  • Added _is_argument_binding_error(func, arguments) — uses inspect.signature().bind() to confirm the failure is a genuine call-boundary error before attaching the schema hint.
  • Extracted shared _resolve_callable_signature_target helper (dedupes the class→run/_run resolution in _tool_parameter_hint).
  • Threaded the exact resolved callable + casted kwargs (bind_target/bind_arguments) per dispatch branch so the bind check matches what was actually invoked.
  • Added regression test test_runtime_valueerror_omits_parameter_hint.

Files modified

  • src/praisonai-agents/praisonaiagents/agent/tool_execution.py
  • src/praisonai-agents/tests/unit/tools/test_tool_resolution_repair.py

Tests

  • test_tool_resolution_repair.py7 passed (6 original + 1 new regression)
  • Full tests/unit/tools/460 passed, 1 skipped, 5 failed. The 5 failures (test_ast_grep_tool.py stdin-approval, test_trust_system.py registry API) are pre-existing on the base commit (verified via stash) and unrelated to this change.

Verdict: Approve

The change is lightweight, backward-compatible, and the one valid reviewer concern is resolved. No scope creep.
· b3250ec

Comment thread src/praisonai-agents/praisonaiagents/agent/tool_execution.py Outdated
@praisonai-triage-agent praisonai-triage-agent Bot added pipeline/merge-ready Eligible for merge gate auto-merge claude-merge-gate-active pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI and removed pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI pipeline/blocked:ci Blocked: CI not green on HEAD pipeline/blocked:cooldown Blocked: post-push or @claude cooldown pipeline/merge-ready Eligible for merge gate auto-merge claude-merge-gate-active labels Jul 23, 2026
@MervinPraison

Copy link
Copy Markdown
Owner

@claude this PR has merge conflicts with main. Please rebase onto latest main, resolve conflicts (keep this PR's intent, merge in newer main logic), run targeted tests, and force-push with --force-with-lease. Comment which files you resolved. Do not bloat the Agent class with additional params — only if absolutely required; we already support many params. Keep the resolution minimal — the aim is a lightweight and powerful package; do not introduce scope creep while resolving conflicts.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

25 similar comments
@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if MERGE_GATE_VERDICT: APPROVE.

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

Merged by Claude PR merge gate (claude-merge-gate.yml).
Verdict: MERGE_GATE_VERDICT: APPROVE
SHA: f64c67a
Method: merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merged-by-gate pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent runtime should self-repair and give actionable feedback on unknown or malformed tool calls

1 participant