skill-as-tool: tell weak models not to retry failed calls#24
Open
cjus wants to merge 1 commit into
Open
Conversation
Under openai/gpt-oss-20b on lmstudio, a skill-as-tool call that hits
iteration_cap (or any deterministic failure) gets retried 3-4× by the
parent model before the loop detector intervenes. The bare envelope
{success:false, error:"iteration_cap"} reads as transient to a weak
model — it doesn't know skill execution is deterministic given
(skill, args).
Expanded the error envelope with explicit retryable:false + plain-prose
hint that names the specific skill the parent should stop calling.
Centralized in `buildSkillErrorPayload` so both error sites (execution
failure, missing context defensive path) emit the same shape. +4 unit
tests pin the MCP content shape, retryable invariant, per-skill hint
identifier, and arbitrary-error-string passthrough.
Error string preserved verbatim — operator log-grep still works.
Retryable/hint are additive; no breaking changes.
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
Live v0.7.0 dogfooding under
openai/gpt-oss-20bon LMStudio surfaced a tool-loop pathology: when a skill-as-tool call hitsiteration_cap(or any deterministic failure), the parent model retries the same skill 3–4× before the loop detector intervenes. Skill execution is deterministic given(skill, args)— retries can't succeed; they waste rounds, accumulate noise in the parent's context, and produce confused final answers.The fix expands the skill-tool error envelope with explicit non-retry signaling that weak local models can act on.
Before:
{"success":false,"error":"iteration_cap"}After:
{ "success": false, "error": "iteration_cap", "retryable": false, "hint": "Do not call 'skills__tldr' again this turn — same input produces the same result. Continue without this skill and answer the user with whatever information you already have." }The raw
errorstring is preserved verbatim so operator log-grepping continues to work.retryableandhintare additive fields a parent model reads to abandon the skill on first failure.Symptom this fixes
Production audit chain (
auditId 220) under LMStudio + gpt-oss-20b, query "list my gmail accounts":gmail_list_accounts✓gmail_search_messagesskills__tldr— each spawns a nested loop hittingmaxIterations:1cap → returnsiteration_caperrorthreshold:3"I'm not sure what you'd like me to log…"— the parent's confused interpretation of repeated tldr failures, not an answer to the actual queryWith this fix the parent sees
retryable:falseon the first tldr failure and produces a final answer instead of cycling.Implementation
src/skill-tools.ts::buildSkillErrorPayload(skillName, errorMessage)— centralized payload builder, exported for test + reusebuildOneSkillToolroute through it (skill execution failure, missingskillToolCtxdefensive path)Why not retry-classify (transient vs permanent)?
Considered marking some errors retryable (e.g. transient network) but rejected: skill execution is purely deterministic for the same
(skill, args). Network errors inside the skill's tool loop are already retried internally byrunToolLoop. Anything that escapes to the skill-tool boundary has exhausted its internal retries and won't recover on a second call from the parent.Test plan
npm run typecheck— cleanbun test— 759/759 pass (+4 vs v0.7.0)src/skill-tools.test.ts: MCP content shape,retryable:falseinvariant, per-skillhintidentifier (so multi-skill turns disambiguate), arbitrary error string passthroughLOCAL_BACKEND=lmstudio LOCAL_MODEL=openai/gpt-oss-20b+ reproduce the gmail/tldr cycle, confirm tldr is abandoned on first failureNo anti-goal reversals
No SDK pin bump. No new runtime deps. Additive envelope fields only.