Skip to content

Feature request: routing rules and a wake budget for agent-to-agent messages #3952

Open

Description

@Raing5Days

Problem

SessionMessage lets any agent session message any other agent session asynchronously, and the target's result comes back to the sender as a follow-up message (session_message_tool.rs:22-23,333-337). A session can therefore spawn a named session of a chosen agent type, hand it a message, receive the answer in its own context and send another one.

Nothing bounds this. Searching that file for depth|limit|budget|chain|cycle|loop|max_ matches only test code (:788-876). There is no call counter, no fan-out limit, no depth field and no notion of a conversation the messages belong to. The vertical direction is the same: AgentSpawn creates a child, AgentSendInput starts another turn in it, AgentList enumerates direct children only, and AgentWait has a 30-minute minimum timeout.

A chain of wake-ups is not one expensive call, it is N complete turns, each with its own system prompt, tool schemas and context. If a session messages three others and each of those messages two more, one user message buys ten or more full agent turns that the person did not ask for.

The likely failure is not a model looping forever. It is more mundane: the tool description says nothing about when not to send, so an agent that is unsure who should handle something does the safest-looking thing and tells everyone. Broadcasting is always available and always permitted, and there is no instruction equivalent to "if you cannot tell, wake nobody and say so".

I also cannot answer, for a given user message, how many agent wake-ups it caused. Not in the UI and not in the logs. That is a missing measurement before it is a missing limit.

Two nearby issues differ. #3626 asks for an activity monitor, which makes wake-ups visible after the fact, and visibility is not a ceiling. #3724 proposes a workspace-level resident entity and asks who schedules work, while this issue asks what governs a channel that already exists between any two agents.

What I want

Two separate things. The second is the one that costs money.

Routing as ordered pure rules. Not a model asked who to wake, but a short ordered list of predicates evaluated against the message and the roster: an explicit mention wins, a single obvious owner gets it, and if nothing matches nobody is woken and the sender is told nothing matched. That last clause is the point. A router that can return an empty set makes "nobody picked this up" a reportable outcome, so the agent can ask the user instead of paying for four guesses. The reference implementation 0xfe-project/eta works this way, with a fixed rule set whose terminal rule wakes nobody and tells the sender why, and with the recipient as the queue key so routing is decided before anything runs.

A wake budget per user message, covering all branches together rather than per agent, since a per-agent budget lets ten agents each spend the full allowance. The shape I suggest: a small number of wake-ups proceed normally, the last one proceeds with a visible note that the budget is nearly spent, and anything after that is delivered as context only, so the message lands in the transcript and no turn starts. The budget resets when the human speaks again, because a human turn is a new decision about how much work to do.

Pair it with delta delivery. A woken agent should receive only rows after its own last_seq, capped in row count and per-row length. Today each wake-up re-establishes context from scratch, and the delta form makes the marginal cost of a wake-up proportional to what is new.

AGENTS.md warns against adding limits and pattern checks to the agent loop as a first response to looping, because that turns the loop into a brittle workflow engine. I read that as being about counts and string matches used as a loop detector. A wake budget never inspects whether something is happening twice. It answers how much work one human message may commission, which is the same category as a context window or an output-token ceiling. It does not block silently, because the over-budget message is still delivered as context and the model can see it was not acted on, so the agent can report it to the user instead of retrying. And it changes what the graph may start, not which tools exist. If maintainers still read it as a workflow engine, the routing half stands alone, since that part only removes the incentive to broadcast.

Acceptance

  • When no routing rule matches, no session is woken and the sender's tool result says so.
  • One user message carries a budget across all branches, and exceeding it delivers the message as context without starting a turn.
  • A human turn resets the budget.
  • The number of wake-ups one user message caused is readable somewhere, in the UI or in the logs.

Nothing here is implemented or tested. The statements above are read from the cited source lines, and the argument about broadcasting comes from reading the tool description rather than from an observed incident. I have not measured a real wake-up chain.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions