More screenshots

    Works with the AI Agents you already use

    Bounded Audited Agent Loop

    by Mohamed Mostafa Metawea

    1

    Run agent turns inside a loop with step caps, token budgets, per-role tool allow-lists and a tool-call audit log.

    $12.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Bounded Audited Agent Loop

    Bounded Audited Agent Loop

    Example session with this skill installed

    My tool-calling agent sometimes loops forever and I cannot see which tools it called. Set up a bounded loop with a step cap, a token budget, a per-role tool allow-list and an audit log.

    • Read your context and instructions
    • Compiled the bounded audited agent

    Summary

    Illustrative outline of what the skill walks you through. This is a sample, not captured output from a live model.

    1. Set MAX_STEPS and a token budget per run.
    2. Define an allow-list of tools per role; anything else is refused with a "not permitted" message.
    3. Truncate large tool results before they go back into the conversation.
    4. Log every tool call (role, tool, arguments, outcome) to an audit table.
    5. If the step cap is hit, record status max_steps instead of ok.

    Next steps

    1. Pick limits that fit your model and budget.
    2. Review the audit log after a few runs.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Run every AI agent turn inside a bounded, audited tool-use loop: a step cap, token budgets, a per-role tool allow-list, and an audit log entry for each tool call. It comes from a small Python reference app (AI Office, standard library plus SQLite) and was checked against that code.

    What it does

    • Caps the loop at a maximum number of steps. If the cap is hit, the status is max_steps, not ok.
    • Tracks token use per run and per task.
    • Refuses any tool the role is not allowed to use and tells the model so.
    • Truncates large tool results so one result cannot fill the context window.
    • Writes an audit record for every tool call.
    • Shows how to assemble the system prompt: role, a skill index, and plain statements of deployment limits.

    How it works

    Step-by-step loop, accounting rules, tool-safety rules and prompt assembly are written out in the skill with the order of checks.

    Frameworks & tools

    Plain Python with the standard library and SQLite. A written playbook, not an installable package.

    Use cases

    • Stopping runaway agent loops before they burn budget.
    • Keeping a per-role record of which tools an agent called.
    • Adding step and token limits to an existing tool-calling agent.

    Known limitations

    Caps protect cost and runaway loops, not output quality. The audit log records attempts, not model reasoning. Needs a model with tool calling.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Frequently Asked Questions

    This skill implements a production-ready execution loop that enforces hard caps on steps and token usage. It prevents runaway costs and infinite loops by moving enforcement from unreliable prompts to the application logic.

    The skill requires a standard Python environment and a database or logging layer. You will use these to store run history and audit rows generated during the agent interactions.

    Every tool request is checked against a per-role allow-list and a tool registry before execution. If an agent attempts to call a tool outside its permissions, the call is blocked, the model is notified of the restriction, and the attempt is recorded in the audit log.

    You receive a code-verified pattern for a bounded loop that outputs a final status, step counts, and token totals. It also generates detailed audit logs containing tool names, arguments, and result previews for post-mortem analysis.

    While the skill protects against runaway costs, it does not guarantee the quality or accuracy of the final output. Additionally, token budgeting relies on accurate reporting from your model provider.

    You can ask your agent to implement a bounded tool-use loop with step caps and a per-role allow-list. Instruct it to use the provided Python pattern to wrap interactions in a safety layer that monitors tokens and logs every tool call to a database.

    New in Agents & Orchestration

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.