Skip to content

Nothing limits how fast an agent can call #417

Open

Description

@Miracle656

Background

Tool calls are handled as they arrive. There is no rate limit, no concurrency
cap and no queue, so an agent in a loop — which is the normal failure mode of an
agent, not an exotic one — can issue calls as fast as it can generate them.

With paid_call in the tool list, that loop costs money (L210). With
bazaar_search it costs an unbounded number of outbound connections from the
host the server runs on.

What to build

  • A concurrency cap on in-flight tool calls, and a rate limit per tool.
  • Exceeding it should be a structured error that tells the agent to slow down,
    with a retry hint — not a silent queue that makes the agent think it is hanging.
  • Expensive tools deserve tighter limits than cheap ones; make the limit
    per-tool rather than global.
  • Count rejections in a metric so a looping agent is visible rather than merely
    expensive.

Acceptance criteria

  • In-flight tool calls are capped
  • A per-tool rate limit exists and is configurable
  • Exceeding a limit returns a structured error with a retry hint
  • Rejections are counted in a metric
  • A test proves a burst is throttled rather than queued indefinitely

Drips Wave · Complexity: Intermediate · 150 points


Repo: Divinity-Labs/Lens. The MCP server is src/mcp/server.ts
(BazaarMcpServer) with error codes in src/mcp/codes.ts. It is started by
npm run mcp:server → examples/mcp-server/run.ts, and there is an agent
example at examples/mcp-server/agent.ts. Tests are tests/mcp.test.ts.

Run the tests: npm test. The tests are vitest, not jest. A single file
is npx vitest run tests/mcp.test.ts.

Load test (prices) is already failing on main. Not your PR.

This surface signs with a real mainnet key. examples/mcp-server/run.ts
requires MCP_AGENT_SECRET_KEY_MAINNET and builds a signer for
stellar:pubnet. Anything you change here can move real money, so prefer
failing closed, and never log, echo or test with a real secret key.

Never elide an address, a contract id or a key in code, comments or
fixtures. A previous batch shortened a contract id and five contributors
invented plausible-looking ids to fill the gap. Write it in full or not at all.

An agent is the least able caller to notice a wrong answer. It will reason
over whatever it is handed, confidently. Prefer a structured error over a
best-effort result.


Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk

Activity

  1. Dev-ElvisTobi commented on Oct 17, 2026

    @Dev-ElvisTobi

    @Dev-ElvisTobi has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hi maintainer! I’d love to work on this issue if it’s still available. I have a good understanding of the requirements and would be happy to implement the solution. Thanks for considering my request!

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Dev-ElvisTobi to this issue.

  2. johnson7104 commented on Oct 17, 2026

    @johnson7104
    Contributor

    @johnson7104 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hi maintainer I would like to solve this and submit
    Please do assign

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @johnson7104 to this issue.

  3. drips-wave commented on Oct 17, 2026

    @drips-wave

    Congratulations, @Dev-ElvisTobi! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

    🧑‍💻 @Dev-ElvisTobi: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions