Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Universal discipline for any LM-driven loop — agent retries, plan-act-observe, multi-agent handoffs, optimiser passes, test-fix cycles. Encodes the one rule every framework documents quietly and every team relearns expensively: the LM in the loop is NEVER a reliable terminator. Termination must be provided by an explicit counter + exit predicate + stagnation signal + escalation path that live OUTSIDE the LM's control. This is a tool- level, framework-agnostic skill. It maps onto LangGraph (recur
SkillScore95/100
Test results 95
3/3 safety checks passed
73%95%of test cases passed +23 pts
Passed 21 of 22 test cases with the skill, and 16 of 22 without it.
6 fixed15 passed either way0 still failing1 broke
One test taskMy LangGraph text-to-SQL agent is failing with GRAPH_RECURSION_LIMIT when Databricks returns query errors. Should I raise recursion_limit=100 in app.py to give the agent enough room to fix its SQL query? Explain the correct architectural solution.
Adds every file the skill has, pinned so you can update it. No account needed.
pip install "decimalai>=0.15"
decimalai skills add agentsope-agentsop-bounded-loop
claude --plugin-dir "$(git rev-parse --show-toplevel 2>/dev/null || pwd)/.agents"The same install from Python, for a notebook or a setup script.
pip install "decimalai>=0.15"from decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
print("Added. Start Claude Code with the command below.")claude --plugin-dir "$(git rev-parse --show-toplevel 2>/dev/null || pwd)/.agents"Type these in a Claude Code session. No account or API key. It writes the skill and any files it bundles, and asks first when its safety rating isn't Passed.
/plugin marketplace add decimal-labs/decimalai-claude-plugins
/plugin install decimalai@decimalai/decimalai:install agentsope-agentsop-bounded-loopThe plugin needs python3 and curl on your machine.
No Python or account. Claude Code picks it up in its next session.
curl -fsSL --create-dirs -o .claude/skills/agentsope-agentsop-bounded-loop/SKILL.md https://app.decimal.ai/s/agentsope-agentsop-bounded-loop/SKILL.md.claude/skills/agentsope-agentsop-bounded-loop/SKILL.mdThis gets SKILL.md only. The skill's 2 other files are not included.
agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[claude-agent-sdk]"
decimalai skills add agentsope-agentsop-bounded-loopimport asyncio
from claude_agent_sdk import ClaudeAgentOptions
from decimalai.claude_agent_sdk import agent_config
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
async def main():
question = "Hello!"
async with support.run(question) as run: # one user message, one run
async for message in run.query(options=ClaudeAgentOptions(max_turns=6)):
print(message)
# In a notebook or async code: await main()
asyncio.run(main())Prefer its own loader? ClaudeAgentOptions(plugins=[skills_plugin()], skills="all") reads the same folder. Use one or the other: a skill delivered both ways reaches the prompt twice.
The same install from Python, for a notebook or a setup script. agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[claude-agent-sdk]"from decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
import asyncio
from claude_agent_sdk import ClaudeAgentOptions
from decimalai.claude_agent_sdk import agent_config
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
async def main():
question = "Hello!"
async with support.run(question) as run: # one user message, one run
async for message in run.query(options=ClaudeAgentOptions(max_turns=6)):
print(message)
# In a notebook or async code: await main()
asyncio.run(main())Prefer its own loader? ClaudeAgentOptions(plugins=[skills_plugin()], skills="all") reads the same folder. Use one or the other: a skill delivered both ways reaches the prompt twice.
No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdimport asyncio
from pathlib import Path
from claude_agent_sdk import ClaudeAgentOptions, query
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
options = ClaudeAgentOptions(system_prompt=f"You are a helpful agent.\n\n{skill}", max_turns=6)
async def main():
async for message in query(prompt="Hello!", options=options):
print(message)
# In a notebook or async code: await main()
asyncio.run(main())This gets SKILL.md only. The skill's 2 other files are not included.
agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[openai-agents]"
decimalai skills add agentsope-agentsop-bounded-loopfrom agents import Agent, Runner
from decimalai.openai_agents import agent_config
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
agent = Agent(
name=support.name,
instructions=support.instructions, # your prompt, then the skill list
tools=[*support.tools], # your tools, then load_skill
)
# In a notebook or async code: result = await Runner.run(agent, "Hello!")
result = Runner.run_sync(agent, "Hello!")Using SandboxAgent? capabilities=[Shell(), decimalai.openai_agents.sandbox_skills()] points its own loader at the same folder.
The same install from Python, for a notebook or a setup script. agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[openai-agents]"from decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
from agents import Agent, Runner
from decimalai.openai_agents import agent_config
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
agent = Agent(
name=support.name,
instructions=support.instructions, # your prompt, then the skill list
tools=[*support.tools], # your tools, then load_skill
)
# In a notebook or async code: result = await Runner.run(agent, "Hello!")
result = Runner.run_sync(agent, "Hello!")Using SandboxAgent? capabilities=[Shell(), decimalai.openai_agents.sandbox_skills()] points its own loader at the same folder.
No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdfrom pathlib import Path
from agents import Agent, Runner
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
agent = Agent(name="support", instructions=f"You are a helpful agent.\n\n{skill}")
# In a notebook or async code: result = await Runner.run(agent, "Hello!")
result = Runner.run_sync(agent, "Hello!")This gets SKILL.md only. The skill's 2 other files are not included.
agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[openai]"
decimalai skills add agentsope-agentsop-bounded-loopimport json
from openai import OpenAI
from decimalai.openai import agent_config
client = OpenAI()
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
def lookup_order(order_id: str) -> str:
return f"Order {order_id} shipped yesterday."
# Your tools, as Chat Completions takes them, and what answers each.
TOOLS = [{"type": "function", "function": {
"name": "lookup_order",
"description": "Look up the status of an order.",
"parameters": {"type": "object", "properties": {"order_id": {"type": "string"}},
"required": ["order_id"]},
}}]
FUNCTIONS = {"lookup_order": lookup_order}
question = "Where is order A1001?"
with support.run(question) as run: # one user message, one run
# run.system is your prompt, then the skill list.
messages = [{"role": "system", "content": run.system}, run.message]
while True:
reply = client.chat.completions.create(
model="gpt-5.4-mini",
messages=messages,
tools=[*TOOLS, *run.tools], # your tools, then load_skill
).choices[0].message
messages.append(reply)
if not reply.tool_calls:
break
for call in reply.tool_calls:
# load_skill is answered by the run; your own tools by FUNCTIONS.
function = FUNCTIONS.get(call.function.name)
messages.append(run.tool_result(call) or {
"role": "tool", "tool_call_id": call.id,
"content": function(**json.loads(call.function.arguments)) if function
else f"There is no tool named {call.function.name!r}.",
})
print(reply.content)
# The Responses API takes run.response_tools instead of run.tools.The same install from Python, for a notebook or a setup script. agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[openai]"from decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
import json
from openai import OpenAI
from decimalai.openai import agent_config
client = OpenAI()
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
def lookup_order(order_id: str) -> str:
return f"Order {order_id} shipped yesterday."
# Your tools, as Chat Completions takes them, and what answers each.
TOOLS = [{"type": "function", "function": {
"name": "lookup_order",
"description": "Look up the status of an order.",
"parameters": {"type": "object", "properties": {"order_id": {"type": "string"}},
"required": ["order_id"]},
}}]
FUNCTIONS = {"lookup_order": lookup_order}
question = "Where is order A1001?"
with support.run(question) as run: # one user message, one run
# run.system is your prompt, then the skill list.
messages = [{"role": "system", "content": run.system}, run.message]
while True:
reply = client.chat.completions.create(
model="gpt-5.4-mini",
messages=messages,
tools=[*TOOLS, *run.tools], # your tools, then load_skill
).choices[0].message
messages.append(reply)
if not reply.tool_calls:
break
for call in reply.tool_calls:
# load_skill is answered by the run; your own tools by FUNCTIONS.
function = FUNCTIONS.get(call.function.name)
messages.append(run.tool_result(call) or {
"role": "tool", "tool_call_id": call.id,
"content": function(**json.loads(call.function.arguments)) if function
else f"There is no tool named {call.function.name!r}.",
})
print(reply.content)
# The Responses API takes run.response_tools instead of run.tools.No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdfrom pathlib import Path
from openai import OpenAI
client = OpenAI()
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
reply = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[
{"role": "system", "content": f"You are a helpful agent.\n\n{skill}"},
{"role": "user", "content": "Hello!"},
],
).choices[0].messageThis gets SKILL.md only. The skill's 2 other files are not included.
agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[anthropic]"
decimalai skills add agentsope-agentsop-bounded-loopimport anthropic
from decimalai.anthropic import agent_config
client = anthropic.Anthropic()
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
question = "Hello!"
with support.run(question) as run: # one user message, one run
answer = client.beta.messages.tool_runner(
model="claude-haiku-5-5",
max_tokens=4096,
system=run.system, # your prompt, then the skill list
tools=[*run.tools], # your tools, then load_skill
messages=[{"role": "user", "content": question}],
).until_done()The same install from Python, for a notebook or a setup script. agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[anthropic]"from decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
import anthropic
from decimalai.anthropic import agent_config
client = anthropic.Anthropic()
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
question = "Hello!"
with support.run(question) as run: # one user message, one run
answer = client.beta.messages.tool_runner(
model="claude-haiku-5-5",
max_tokens=4096,
system=run.system, # your prompt, then the skill list
tools=[*run.tools], # your tools, then load_skill
messages=[{"role": "user", "content": question}],
).until_done()No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdfrom pathlib import Path
import anthropic
client = anthropic.Anthropic()
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
reply = client.messages.create(
model="claude-haiku-5-5",
max_tokens=4096,
system=f"You are a helpful agent.\n\n{skill}",
messages=[{"role": "user", "content": "Hello!"}],
)This gets SKILL.md only. The skill's 2 other files are not included.
agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[google-genai]"
decimalai skills add agentsope-agentsop-bounded-loopfrom google import genai
from google.genai import types
from decimalai.google_genai import agent_config
client = genai.Client()
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
def lookup_order(order_id: str) -> str:
return f"Order {order_id} shipped yesterday."
# Your functions, as declarations for the model, and what answers each.
TOOLS = [{"function_declarations": [{
"name": "lookup_order",
"description": "Look up the status of an order.",
"parameters_json_schema": {"type": "object", "properties": {"order_id": {"type": "string"}},
"required": ["order_id"]},
}]}]
FUNCTIONS = {"lookup_order": lookup_order}
question = "Where is order A1001?"
with support.run(question) as run: # one user message, one run
config = types.GenerateContentConfig(
system_instruction=run.system, # your prompt, then the skill list
tools=[*TOOLS, *run.tool_params], # your functions, then load_skill
)
contents = [{"role": "user", "parts": [{"text": run.message}]}]
while True:
response = client.models.generate_content(
model="gemini-3.5-flash", contents=contents, config=config,
)
if not response.function_calls:
break
contents.append(response.candidates[0].content)
parts = []
for call in response.function_calls:
# load_skill is answered by the run; your own functions by FUNCTIONS.
# A loop of your own rather than automatic function calling, which
# raises KeyError when the model asks for a function you did not pass.
function = FUNCTIONS.get(call.name)
parts.append(run.tool_result(call) or {"function_response": {
"name": call.name, "id": call.id,
"response": {"result": function(**(call.args or {})) if function
else f"There is no function named {call.name!r}."},
}})
contents.append({"role": "user", "parts": parts})
print(response.text)The same install from Python, for a notebook or a setup script. agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[google-genai]"from decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
from google import genai
from google.genai import types
from decimalai.google_genai import agent_config
client = genai.Client()
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
def lookup_order(order_id: str) -> str:
return f"Order {order_id} shipped yesterday."
# Your functions, as declarations for the model, and what answers each.
TOOLS = [{"function_declarations": [{
"name": "lookup_order",
"description": "Look up the status of an order.",
"parameters_json_schema": {"type": "object", "properties": {"order_id": {"type": "string"}},
"required": ["order_id"]},
}]}]
FUNCTIONS = {"lookup_order": lookup_order}
question = "Where is order A1001?"
with support.run(question) as run: # one user message, one run
config = types.GenerateContentConfig(
system_instruction=run.system, # your prompt, then the skill list
tools=[*TOOLS, *run.tool_params], # your functions, then load_skill
)
contents = [{"role": "user", "parts": [{"text": run.message}]}]
while True:
response = client.models.generate_content(
model="gemini-3.5-flash", contents=contents, config=config,
)
if not response.function_calls:
break
contents.append(response.candidates[0].content)
parts = []
for call in response.function_calls:
# load_skill is answered by the run; your own functions by FUNCTIONS.
# A loop of your own rather than automatic function calling, which
# raises KeyError when the model asks for a function you did not pass.
function = FUNCTIONS.get(call.name)
parts.append(run.tool_result(call) or {"function_response": {
"name": call.name, "id": call.id,
"response": {"result": function(**(call.args or {})) if function
else f"There is no function named {call.name!r}."},
}})
contents.append({"role": "user", "parts": parts})
print(response.text)No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdfrom pathlib import Path
from google import genai
from google.genai import types
client = genai.Client()
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
response = client.models.generate_content(
model="gemini-3.5-flash",
contents="Hello!",
config=types.GenerateContentConfig(system_instruction=f"You are a helpful agent.\n\n{skill}"),
)This gets SKILL.md only. The skill's 2 other files are not included.
agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[langchain]" langchain-openai
decimalai skills add agentsope-agentsop-bounded-loopfrom langchain.agents import create_agent
from decimalai.langchain import agent_config
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
agent = create_agent(
"openai:gpt-5.4-mini",
tools=[], # your tools; the middleware adds load_skill
middleware=[support.middleware], # your prompt, the skill list and load_skill
)
result = agent.invoke({"messages": [{"role": "user", "content": "Hello!"}]})The same install from Python, for a notebook or a setup script. agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[langchain]" langchain-openaifrom decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
from langchain.agents import create_agent
from decimalai.langchain import agent_config
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
agent = create_agent(
"openai:gpt-5.4-mini",
tools=[], # your tools; the middleware adds load_skill
middleware=[support.middleware], # your prompt, the skill list and load_skill
)
result = agent.invoke({"messages": [{"role": "user", "content": "Hello!"}]})No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdfrom pathlib import Path
from langchain.agents import create_agent
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
agent = create_agent("openai:gpt-5.4-mini", tools=[], system_prompt=f"You are a helpful agent.\n\n{skill}")
result = agent.invoke({"messages": [{"role": "user", "content": "Hello!"}]})This gets SKILL.md only. The skill's 2 other files are not included.
CrewAI's own skill loader reads the installed folder. No DecimalAI account needed.
pip install "decimalai>=0.16" "crewai>=1.15.27"
decimalai skills add agentsope-agentsop-bounded-loopimport decimalai.crewai
from crewai import Agent, Crew, Task
agent = Agent(
role="Support", goal="Help the customer", backstory="A support agent.",
llm=llm, # your own CrewAI LLM
skills=decimalai.crewai.skills(), # the installed folder
tools=decimalai.crewai.skill_tools(), # reads a skill's files, runs its scripts
)
task = Task(description="Hello!", expected_output="an answer", agent=agent)
Crew(agents=[agent], tasks=[task]).kickoff()The same install from Python, for a notebook or a setup script. CrewAI's own skill loader reads the installed folder. No DecimalAI account needed.
pip install "decimalai>=0.16" "crewai>=1.15.27"from decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
import decimalai.crewai
from crewai import Agent, Crew, Task
agent = Agent(
role="Support", goal="Help the customer", backstory="A support agent.",
llm=llm, # your own CrewAI LLM
skills=decimalai.crewai.skills(), # the installed folder
tools=decimalai.crewai.skill_tools(), # reads a skill's files, runs its scripts
)
task = Task(description="Hello!", expected_output="an answer", agent=agent)
Crew(agents=[agent], tasks=[task]).kickoff()No DecimalAI package. CrewAI's own loader reads the folder, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdfrom pathlib import Path
from crewai import Agent, Crew, Task
agent = Agent(
role="Support", goal="Help the customer", backstory="A support agent.",
llm=llm, # your own CrewAI LLM
skills=[Path(".agents/skills")],
)
task = Task(description="Hello!", expected_output="an answer", agent=agent)
Crew(agents=[agent], tasks=[task]).kickoff()This gets SKILL.md only. The skill's 2 other files are not included.
agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[adk]"
decimalai skills add agentsope-agentsop-bounded-loopfrom decimalai.adk import DecimalAIPlugin, agent_config
from google.adk.agents import LlmAgent
from google.adk.apps import App
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
agent = LlmAgent(
name="support", # ADK needs a Python identifier
model="gemini-3.5-flash",
instruction=support.instruction, # your prompt, then the skill list
tools=[*support.tools], # your tools, then load_skill
)
# DecimalAIPlugin makes each invocation of runners built from this App one trace.
app = App(name="support", root_agent=agent, plugins=[DecimalAIPlugin()])Prefer ADK's own loader? SkillToolset(skills=decimalai.adk.skills(), ...) reads the same folder. Use one or the other: a skill delivered both ways reaches the prompt twice.
The same install from Python, for a notebook or a setup script. agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[adk]"from decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
from decimalai.adk import DecimalAIPlugin, agent_config
from google.adk.agents import LlmAgent
from google.adk.apps import App
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
agent = LlmAgent(
name="support", # ADK needs a Python identifier
model="gemini-3.5-flash",
instruction=support.instruction, # your prompt, then the skill list
tools=[*support.tools], # your tools, then load_skill
)
# DecimalAIPlugin makes each invocation of runners built from this App one trace.
app = App(name="support", root_agent=agent, plugins=[DecimalAIPlugin()])Prefer ADK's own loader? SkillToolset(skills=decimalai.adk.skills(), ...) reads the same folder. Use one or the other: a skill delivered both ways reaches the prompt twice.
No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdfrom pathlib import Path
from google.adk.agents import LlmAgent
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
agent = LlmAgent(
name="support",
model="gemini-3.5-flash",
instruction=lambda context: f"You are a helpful agent.\n\n{skill}",
)This gets SKILL.md only. The skill's 2 other files are not included.
agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[pydantic-ai]"
decimalai skills add agentsope-agentsop-bounded-loopfrom pydantic_ai import Agent
from decimalai.pydantic_ai import agent_config
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
agent = Agent(
"openai:gpt-4o-mini",
name=support.name,
tools=[], # your tools; the capability adds load_skill
capabilities=[support], # your prompt, the skill list and load_skill
)
# In a notebook or async code: result = await agent.run("Hello!")
result = agent.run_sync("Hello!")On the Pydantic AI harness, decimalai.pydantic_ai_harness.skills(project) uses its own loader instead.
The same install from Python, for a notebook or a setup script. agent_config() hands your agent the skill. With no DecimalAI key it reads your project's files and sends nothing. Needs SDK 0.27 or newer.
pip install "decimalai[pydantic-ai]"from decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
from pydantic_ai import Agent
from decimalai.pydantic_ai import agent_config
# With no DECIMAL_API_KEY this reads the skills your project lists, from disk.
support = agent_config("support", fallback="You are a helpful agent.")
agent = Agent(
"openai:gpt-4o-mini",
name=support.name,
tools=[], # your tools; the capability adds load_skill
capabilities=[support], # your prompt, the skill list and load_skill
)
# In a notebook or async code: result = await agent.run("Hello!")
result = agent.run_sync("Hello!")On the Pydantic AI harness, decimalai.pydantic_ai_harness.skills(project) uses its own loader instead.
No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdfrom pathlib import Path
from pydantic_ai import Agent
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
agent = Agent("openai:gpt-4o-mini", instructions=f"You are a helpful agent.\n\n{skill}")
# In a notebook or async code: result = await agent.run("Hello!")
result = agent.run_sync("Hello!")This gets SKILL.md only. The skill's 2 other files are not included.
Deep Agents' own skill loader reads the installed folder. No DecimalAI account needed.
pip install "decimalai>=0.16" deepagents
decimalai skills add agentsope-agentsop-bounded-loopimport decimalai.deepagents
from deepagents import create_deep_agent
agent = create_deep_agent(model=model, **decimalai.deepagents.skills())
agent.invoke({"messages": [{"role": "user", "content": "Hello!"}]})The default backend reads files but has no shell. To run a skill's scripts, pass skills(backend=LocalShellBackend(...)).
The same install from Python, for a notebook or a setup script. Deep Agents' own skill loader reads the installed folder. No DecimalAI account needed.
pip install "decimalai>=0.16" deepagentsfrom decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
import decimalai.deepagents
from deepagents import create_deep_agent
agent = create_deep_agent(model=model, **decimalai.deepagents.skills())
agent.invoke({"messages": [{"role": "user", "content": "Hello!"}]})The default backend reads files but has no shell. To run a skill's scripts, pass skills(backend=LocalShellBackend(...)).
No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdfrom pathlib import Path
from deepagents import create_deep_agent
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
agent = create_deep_agent(model=model, system_prompt=f"You are a helpful agent.\n\n{skill}")
agent.invoke({"messages": [{"role": "user", "content": "Hello!"}]})This gets SKILL.md only. The skill's 2 other files are not included.
Its own skill loader reads the installed folder. No DecimalAI account needed.
pip install "decimalai>=0.16" agent-framework
decimalai skills add agentsope-agentsop-bounded-loopimport asyncio
from agent_framework import Agent
from decimalai.agent_framework import skills
agent = Agent(client=client, instructions="You are a helpful agent.", context_providers=[skills()])
asyncio.run(agent.run("Hello!"))It caches skills by default, so restart the process after decimalai skills update.
The same install from Python, for a notebook or a setup script. Its own skill loader reads the installed folder. No DecimalAI account needed.
pip install "decimalai>=0.16" agent-frameworkfrom decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
import asyncio
from agent_framework import Agent
from decimalai.agent_framework import skills
agent = Agent(client=client, instructions="You are a helpful agent.", context_providers=[skills()])
asyncio.run(agent.run("Hello!"))It caches skills by default, so restart the process after decimalai skills update.
No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdimport asyncio
from pathlib import Path
from agent_framework import Agent
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
agent = Agent(client=client, instructions=f"You are a helpful agent.\n\n{skill}")
asyncio.run(agent.run("Hello!"))This gets SKILL.md only. The skill's 2 other files are not included.
Strands' own skill loader reads the installed folder. No DecimalAI account needed.
pip install "decimalai>=0.16" strands-agents
decimalai skills add agentsope-agentsop-bounded-loopfrom decimalai.strands import skills
from strands import Agent
from strands.vended_tools import file_editor, shell
agent = Agent(
model=model, # always pass one: the default is Amazon Bedrock
system_prompt="You are a helpful agent.",
tools=[file_editor, shell],
plugins=[skills()],
)
agent("Hello!")Strands loads an agent's skills once, so build the agent again after decimalai skills update.
The same install from Python, for a notebook or a setup script. Strands' own skill loader reads the installed folder. No DecimalAI account needed.
pip install "decimalai>=0.16" strands-agentsfrom decimalai import skillpkg
# Writes .agents/skills and .decimal/skills.toml. Safe to run twice.
result = skillpkg.add("agentsope-agentsop-bounded-loop")
if result.exit_code:
raise SystemExit(result.problems)
from decimalai.strands import skills
from strands import Agent
from strands.vended_tools import file_editor, shell
agent = Agent(
model=model, # always pass one: the default is Amazon Bedrock
system_prompt="You are a helpful agent.",
tools=[file_editor, shell],
plugins=[skills()],
)
agent("Hello!")Strands loads an agent's skills once, so build the agent again after decimalai skills update.
No DecimalAI package. The whole skill goes in every prompt, and nothing pins or updates it.
.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdfrom pathlib import Path
from strands import Agent
skill = Path(".agents/skills/agentsope-agentsop-bounded-loop/SKILL.md").read_text()
agent = Agent(model=model, system_prompt=f"You are a helpful agent.\n\n{skill}")
agent("Hello!")This gets SKILL.md only. The skill's 2 other files are not included.
Adds every file the skill has, pinned so you can update it. Cursor, Copilot, Cline and Warp read this folder by themselves.
pip install "decimalai>=0.15"
decimalai skills add agentsope-agentsop-bounded-loopNo Python or account. Cursor, Copilot, Cline and Warp read this folder by themselves.
curl -fsSL --create-dirs -o .agents/skills/agentsope-agentsop-bounded-loop/SKILL.md https://app.decimal.ai/s/agentsope-agentsop-bounded-loop/SKILL.md.agents/skills/agentsope-agentsop-bounded-loop/SKILL.mdThis gets SKILL.md only. The skill's 2 other files are not included.
Give its text to your model as instructions. No account or package needed.
This gets SKILL.md only. The skill's 2 other files are not included.
Raw files: /s/agentsope-agentsop-bounded-loop/SKILL.md · /s/agentsope-agentsop-bounded-loop.json
Fetch the file and give its text to your model as instructions. No account or package needed.
curl -fsSL https://app.decimal.ai/s/agentsope-agentsop-bounded-loop/SKILL.mdcurl -fsSL https://app.decimal.ai/s/agentsope-agentsop-bounded-loop.jsonThis gets SKILL.md only. The skill's 2 other files are not included.
You don't need a DecimalAI account.
Saved prompts and skills, pinned versions, and traces of this skill in your runs. DecimalAI does not run your agent.
Claude Code reads files from your project, so DecimalAI config does not apply there.
On Claude Agent SDK: save the skill to an agent here, set DECIMAL_API_KEY, and the same code uses it with no command to run. Changes you save reach the next run with no redeploy.
On OpenAI Agents: save the skill to an agent here, set DECIMAL_API_KEY, and the same code uses it with no command to run. Changes you save reach the next run with no redeploy.
On OpenAI SDK: save the skill to an agent here, set DECIMAL_API_KEY, and the same code uses it with no command to run. Changes you save reach the next run with no redeploy.
On Anthropic: save the skill to an agent here, set DECIMAL_API_KEY, and the same code uses it with no command to run. Changes you save reach the next run with no redeploy.
On Gemini API: save the skill to an agent here, set DECIMAL_API_KEY, and the same code uses it with no command to run. Changes you save reach the next run with no redeploy.
On LangChain: save the skill to an agent here, set DECIMAL_API_KEY, and the same code uses it with no command to run. Changes you save reach the next run with no redeploy.
On CrewAI: set DECIMAL_API_KEY and add decimalai.init(crewai=True) to record runs and skill use. The skill version stays in your repo.
On Google ADK: save the skill to an agent here, set DECIMAL_API_KEY, and the same code uses it with no command to run. Changes you save reach the next run with no redeploy.
On Pydantic AI: save the skill to an agent here, set DECIMAL_API_KEY, and the same code uses it with no command to run. Changes you save reach the next run with no redeploy.
On Deep Agents: set DECIMAL_API_KEY and add decimalai.init(langchain=True) to record runs and skill use. The skill version stays in your repo.
On Microsoft Agent Framework: set DECIMAL_API_KEY and add decimalai.init(otel=True, agent_name="support") to record runs and skill use. The skill version stays in your repo.
On Strands: set DECIMAL_API_KEY and add decimalai.init(otel=True, agent_name="support") to record runs and skill use. The skill version stays in your repo.
Editors read files from your project, so DecimalAI config does not apply there.
Anywhere else: record a use with decimalai.log_skill_activation() inside a trace.
Source posture: every load-bearing claim is cited inline with a short tag resolved against
references/R1-source-evidence.mdandreferences/R2-cross-framework.md. Examples cite the real GitHub issues they're distilled from.
Activate this skill when any of the following is true:
GRAPH_RECURSION_LIMIT (LangGraph), MaxIterationsExceeded (LangChain
AgentExecutor), "agent exceeded max_iter" (CrewAI), max_turns reached
(OpenAI Agents SDK), stop_reason="max_tokens" mid-tool-use (Anthropic).recursion_limit=200 — this is the canonical anti-pattern this skill
exists to prevent.[gh/crewai-330]).Do not activate for: single LLM calls, one-shot RAG queries, stateless tool pipelines, or flows where the cycle is provably bounded by data (e.g., "iterate once per row in this fixed list").
Every loop body must produce a state change that proves progress — and the proof must be checkable without calling another LM.
Read that twice. It contains four claims:
The body must change state. A no-op iteration (same input → same output) is the definition of a stuck loop. If your body might return the same value twice, the loop is already broken; the safety net just hasn't fired yet.
The change must be progress, not just diff. A retry that says "I tried again, same error" is a change but not progress. The witness has to be monotone: counter strictly increasing, error list strictly shrinking, confidence strictly rising, or a new fact added to the plan.
The proof must be checkable. Pure Python. A dict.get("retries") < N,
not await llm.ainvoke("are we done?"). If you ask the LM to evaluate
termination, you've recreated the problem one level up — now that loop
needs bounding.
The LM is not allowed to vote. It can suggest finality
(stop_reason="end_turn", final_answer tool, etc.) but the framework
must verify against the predicate before terminating. Otherwise an LM
that always says "let me try once more" runs forever.
Every framework ships a default cap:
recursion_limit=25 [lc-docs/errors]Agent.max_iter=20, Crew.max_rpm [crewai-docs/agents]AgentExecutor: max_iterations=15 (deprecated default)Run.max_turnsmax_tokens per call (per-call, not per-loop)These are billing safety nets, not control flow. The LangGraph docs say so explicitly:
"If you are not expecting your graph to go through many iterations, you likely have a cycle. Check your logic for infinite loops." —
[lc-docs/errors]https://docs.langchain.com/oss/python/langgraph/errors/GRAPH_RECURSION_LIMIT
And the cheatsheet adds:
"Hitting the limit typically indicates an underlying design flaw. The recursion limit is a safety net for runaway code, not a primary control flow mechanism." —
[cheatsheet/gotchas]
When you raise the limit to "fix" the error, you've moved the bug
further away, not removed it. The text-to-SQL agent in [gh/6731]
would have hit recursion_limit=100 after burning 5× the Databricks
quota.
A bounded loop has three independent termination axes; you need at least two firing in series:
┌─── (a) success predicate met → exit success
│
[loop body] ────┼─── (b) counter / budget exhausted → exit escalation
│
└─── (c) stagnation detected → exit escalation
If you only have (a), the LM controls termination — it doesn't. If you only have (b), you'll burn the budget on N identical iterations. If you only have (c), one-shot flake will look like success.
Compose all three.
A coder agent walks this top-down. Each step has a decision gate — answer "no" and you go back, not forward.
Before adding any bound, write down on paper:
Gate: if you can't name the witness, you don't yet understand the loop well enough to bound it. Don't add a counter — go think.
Common witnesses by workflow shape:
| Workflow | Witness |
|---|---|
| Tool-call → error → retry | last_error text must change (or counter increments) |
| Plan → act → observe | plan_revision: int strictly increases |
| Draft → critique → revise | critique length shrinks OR revision_count increments with non-empty diff |
| Test → fix → re-test | failing_tests set strictly shrinks |
| Optimiser sweep | best_metric strictly improves (with patience) |
| Multi-agent handoff | task_status transitions through a state machine, not "in_progress → in_progress → ..." |
Counter discipline:
max_iter — that is the CrewAI ping-pong bug [gh/crewai-330].Annotated[int, operator.add] in LangGraph,
not a state replace.Pseudocode (framework-agnostic):
def loop_body(state):
new_state = do_one_iteration(state)
new_state["retries"] = state.get("retries", 0) + 1
return new_state
def should_continue(state) -> Literal["continue", "give_up"]:
if state["retries"] >= MAX_RETRIES:
return "give_up"
if success_predicate(state):
return "end"
return "continue"
The counter alone wastes (N-1) iterations on identical work. Add a progress witness comparison:
def should_continue(state):
if state.get("last_witness") == state.get("witness"):
return "give_up_stagnant"
if state["retries"] >= MAX_RETRIES:
return "give_up_budget"
if success_predicate(state):
return "end"
return "continue"
Stagnation signals worth detecting:
last_error two iterations running.tool_calls hash (same tool, same args) two iterations.plan_revision did not increment.failing_tests did not shrink (test-fix loop).When stagnation fires, always escalate — don't retry.
The LM must see the loop counter and the last error / last witness. If it doesn't, it will happily repeat. Concretely:
retries and last_error in the messages
passed to the LLM node — or render them into the system prompt at
each iteration.context=[...], not in Crew.memory (which is muddier)."Attempt {n} of {N}. Previous error: {err}. If you cannot fix it on this attempt, return final_answer with status=failed."Without this, the LM thinks it's on iteration 1 forever. The framework's counter is in your code; the behavioural counter must be in the prompt.
The framework's safety net exists for a reason — runaway billing. Don't disable it. Instead, build the graceful give-up that catches the counter/stagnation exit:
give_up node that calls interrupt({"reason": ...}),
preserving the full state for a human or outer agent to inspect.Task with human_input=True that fires when the
main task fails the validation in expected_output.human_escalation tool that the model is forced to
call when attempt == N.Run.status == "incomplete" /
incomplete_reason == "max_turns" in the caller and surface to user.Rule of thumb: a loop without a give-up branch is a loop that fails to a stack trace. That's not graceful.
Even with counter + witness + escalation, each individual iteration can be expensive (one tool call doing a 200k-token web search). Add:
asyncio.wait_for(loop, timeout=T) at the
outermost caller.max_rpm, OpenAI tier limits, Anthropic
requests_per_minute. Hit these before you hit the model's
rate-limit error which adds backoff + more retries.These are not redundant with the counter — they're orthogonal axes. A 3-iteration loop where one iteration runs for 4 hours still wedges your system.
Write a regression test that injects a permanent failure and asserts:
This is the same shape as [gh/6731]'s recommended fix: "Add a
regression test that injects a permanent SQL error and asserts the graph
terminates within 3 iterations." Steal that pattern.
Each operation is a primitive a coder agent can invoke. Format: Trigger → Action → Output → Evidence.
Annotated[int, operator.add];
CrewAI: shared dict in Crew context or Flow state; Claude SDK: app
variable). Increment inside the loop body; check in the exit predicate.[gh/6731] (text-to-SQL fix), [lc-docs/errors]
("explicit termination conditions are the right answer").last_error, last_tool_call_hash, last_witness) in state. In the
exit predicate, compare current vs previous before checking the
counter. Same → exit stagnant, don't increment.[gh/6731] (LLM was retrying identical query 20 times —
stagnation would have fired after 1).give_up node → interrupt({"reason", "state"}). CrewAI:
fallback Task(human_input=True) or Flow @listen("failed") branch.
Claude SDK: human_escalation tool injection. OpenAI Agents: catch
incomplete_reason == "max_turns" in caller.[lc-blog/interrupt] four-pattern table; Aider's REPL
return-to-human on failed test.asyncio.wait_for at outer caller; enforce per-model
requests_per_minute. Any one tripping → escalation (OP-3).max_rpm;
OpenAI max_completion_tokens / max_prompt_tokens on Run.[cheatsheet/gotchas] "Treat each node like a pure
function — return a partial state update"; LangChain best practices.recursion_limit / max_iter."[gh/6731] maintainer marked "not planned" — i.e., this
is by design. [cheatsheet/gotchas] "indicates an underlying design
flaw."Source: [gh/6731]
(https://github.com/langchain-ai/langgraph/issues/6731), maintainer
labelled "not planned."
困境: A team built a text-to-SQL agent on LangGraph 1.0.6. When
the Databricks query returned an error, the agent retried the same
broken SQL 20 times until the default recursion_limit=25 fired. It
had worked on 0.6.x; the upgrade exposed the missing exit condition.
约束:
决策步骤:
recursion_limit to 100." That makes the
bleeding worse and confirms the cheatsheet's diagnosis
[cheatsheet/gotchas].class S(TypedDict):
messages: Annotated[list[AnyMessage], add_messages]
retries: Annotated[int, operator.add]
last_error: str | None
state["last_error"] is the same
as the new error, route to give-up — don't burn 2 more attempts on
the identical broken query.last_error into the next LLM prompt — the content of
the SQL error usually tells the LLM whether to retry or abandon.interrupt() to ask the user:
"Tried 3 times, got: {last_error}. Should I rewrite the query
differently or stop?"结果: Loop bounded at 3 iterations. Stagnation typically fires on iteration 2 (same query, same error). Quota cost capped. Failure mode observable in LangSmith. Maintainer-labelled-"not-planned" issue becomes a non-issue without an upstream patch.
可提取的操作: OP-1 + OP-2 + OP-3 are mandatory for any cyclic graph. The LM is never the terminator.
Source: github.com/crewAIInc/crewAI/issues/330
困境: A team running CrewAI in hierarchical mode set
allow_delegation=True on all 3 worker agents. Agent A delegated to
B; B delegated back to A; A delegated to C; C delegated back to A. The
per-agent max_iter=20 did NOT propagate across the handoffs — every
delegation reset the count. Token bill 10× expected; the loop only
ended when OpenAI rate-limited them.
约束:
决策步骤:
max_iter per agent to 100." The bug is that
max_iter doesn't cross handoffs — raising it does nothing
[gh/crewai-330].allow_delegation=False on all worker agents. Only the
manager agent gets delegation. This kills the cycle structurally
— the CrewAI canonical advice from [azguards.com].Crew context (Flow state
if using Flows). Each delegation increments; manager checks before
dispatching.(from_agent, to_agent, task_id) —
if the same triple recurs, route to the manager's
"I-can't-resolve-this" fallback Task with human_input=True.asyncio.wait_for(crew.kickoff_async(...), timeout=600) — wall-clock cap regardless of token budget.@listen gives explicit routing
[crewai-docs/flows], eliminating the LM-driven handoff.结果: Cycle eliminated structurally (no worker delegates back). Token bill returns to expected level. Audit trail preserved (the manager owns dispatch; the handoff counter logs each).
可提取的操作:
max_iter is a useful
inner net but not a sufficient outer net.max_iter not crossing handoffs), the right move is to remove the
primitive's source of failure (allow_delegation=False), not
raise its limit.Concrete don'ts. Each has a real-world example.
❌ Raise recursion_limit / max_iter / max_turns to "fix" a
loop. This is the anti-pattern this skill exists to name. The
framework defaults are circuit breakers; raising them moves the
failure further away while doubling the cost. Source: [gh/6731]
maintainer "not planned"; [cheatsheet/gotchas] "indicates an
underlying design flaw."
❌ Let the LM vote on termination via reflection. Calling
llm.invoke("are we done?") to decide whether to exit recreates the
problem one level up — and the answer is biased ("let me just check
one more thing"). The LM may suggest finality (a final_answer
tool, stop_reason="end_turn"); the framework code must verify.
❌ Bound only by tokens. A slow loop with cheap iterations never hits the token cap and runs for hours. Token budget is one of three axes (OP-4), not the whole bound.
❌ Per-agent max_iter in multi-agent systems with delegation.
CrewAI's Agent.max_iter does not propagate across delegation
handoffs [gh/crewai-330]. The counter must be shared.
❌ Bound without an escalation path. A loop that hits
recursion_limit and raises is not "bounded" in any useful sense —
it's "crashed with stacktrace." A bounded loop has a clean give-up
branch (OP-3).
❌ Counter that the LM cannot see. If you increment a counter in Python state but never surface "attempt N of M, previous error: X" in the LM's prompt, the LM thinks it's on attempt 1 forever and emits the same plan. Counter must be in the behaviour, not just the control plane.
❌ "Stop when the metric stops improving" with no patience or cap. Classic optimiser footgun. The metric can plateau and resume; the loop should be bounded by both a max-step count and a patience counter — DSPy and W&B sweeps document this. Source: optimiser docs across DSPy / Optuna / W&B.
❌ Bound the framework's max_iter but not the outer caller. If the LM raises an exception inside the loop body and your retry decorator wraps the whole call, the bounded loop becomes an unbounded retry. Bound at every layer the framework gives you.
❌ Use interrupt() / human_input=True only on success. The
give-up branch is the most important place for human-in-the-loop —
that's where the agent is admitting it's stuck. Routing the failure
to a stack trace instead of a human wastes the diagnostic moment.
The same termination contract expressed in each framework's vocabulary. Use this table when porting a bounded loop between frameworks — the shape is identical, only the names change.
| Concept | LangGraph | CrewAI | Claude SDK | OpenAI Agents | DSPy |
|---|---|---|---|---|---|
| Iteration counter | state["retries"]: Annotated[int, operator.add] | shared dict in Crew context or Flow state | app-side for i in range(max_iter): | Run(max_turns=N) config | optimiser max_bootstrapped_demos |
| Exit predicate | conditional edge function returning "END" | manager Task validating expected_output | if stop_reason == "end_turn": break | Run.status == "completed" | metric early-stopping (with explicit patience) |
| Safety-net default | recursion_limit=25 | Agent.max_iter=20 + Crew.max_rpm | max_tokens per call | max_turns (no default) | none (dataset size) |
| Progress witness | typed state field updated by node | Task expected_output mandates delta | validator on tool output | function schema enforces non-empty delta | metric must strictly improve |
| Stagnation signal | compare state["last_X"] == state["X"] in conditional edge | task callback hashes output → stored in context | compare tool_use blocks across iterations | compare tool_calls in Run steps | patience counter (steps since best) |
| Escalation | interrupt({"reason": ...}) node | fallback Task with human_input=True | tool call to human channel | incomplete_reason == "max_turns" handler | terminate optimiser + log |
| Resume after escalation | Command(resume=...) | re-kickoff() with appended human input | re-invoke with new user message | submit_tool_outputs(...) | re-run with adjusted config |
| Outer safety bounds | wrap graph.ainvoke in asyncio.wait_for | Crew.max_rpm + outer wait_for | sum usage.input_tokens + usage.output_tokens across calls; wall-clock | Run(max_completion_tokens, max_prompt_tokens) | num_threads budget + wall-clock |
Translation example. "Text-to-SQL agent retries the broken query 20 times" expressed in three frameworks:
| LangGraph | CrewAI | Claude SDK | |
|---|---|---|---|
| Counter | retries: Annotated[int, operator.add] in TypedDict | Crew(memory=False, context={"retries": 0}) updated in callback | attempt = 0 in caller |
| Increment | LLM node returns {"retries": 1} | Task on_complete callback updates dict | attempt += 1 after each Messages call |
| Exit | conditional edge → END when retries >= 3 | manager Task aborts when context counter ≥ 3 | if attempt >= 3: break |
| Witness | last_error: str field updated by tool node | last_error key in Crew context | track in caller variable |
| Stagnation | edge function compares last_error | callback compares stored vs new | caller compares strings |
| Escalation | interrupt({"err": state["last_error"]}) node | fallback Task(human_input=True) | tool call human_escalate(err) |
| Outer net | recursion_limit=10 (leave default low) | Crew(max_rpm=30) + wait_for(60s) | max_tokens=2048 + wait_for(60s) |
The translation is mechanical because the contract is universal. That is the entire point of this skill.
Short tags resolved against references/R1-source-evidence.md and
references/R2-cross-framework.md:
[gh/6731] = github.com/langchain-ai/langgraph/issues/6731 — text-to-SQL
recursion_limit, maintainer "not planned"[gh/crewai-330] = github.com/crewAIInc/crewAI/issues/330 — delegation
ping-pong; related #4783, #2606[lc-docs/errors] = docs.langchain.com/oss/python/langgraph/errors/GRAPH_RECURSION_LIMIT[lc-blog/interrupt] = www.langchain.com/blog/making-it-easier-to-build-human-in-the-loop-agents-with-interrupt[cheatsheet/gotchas] = sumanmichael.github.io/langgraph-cheatsheet/cheatsheet/faqs-gotchas/[crewai-docs/agents] = docs.crewai.com/en/concepts/agents[crewai-docs/flows] = docs.crewai.com/en/concepts/flows[azguards.com] = azguards.com/technical/the-delegation-ping-pong-breaking-infinite-handoff-loops-in-crewai-hierarchical-topologies/[anthropic-docs] = docs.anthropic.com/en/api/messages — Messages API +
Agent SDK "step budget" pattern[dspy-docs] = dspy.ai/docs/building-blocks/optimizers — declared
evaluation budget[openai-agents-docs] = platform.openai.com/docs/assistants — Run
config max_turns, max_completion_tokens, max_prompt_tokensEvery LM loop must carry an explicit counter in state, a progress
witness the loop body must update, a stagnation detector that
compares the witness across iterations, and a graceful escalation
branch when either fires. Never raise the framework's
recursion_limit / max_iter / max_turns to "fix" a loop —
that limit is a billing safety net, not control flow, and raising it
moves the failure further away while burning more tokens. The LM in
the loop is never a reliable terminator. Source-of-truth case:
LangGraph issue #6731
marked "not planned" — the framework will not save you; the discipline
must.
Skills that do similar work, with their headline benchmark lift.
From the same source and nearby in the catalogue.