Which tool?
gateway_status is easy to confuse with its two siblings. This decision diagram picks the right one.
Quick Start
1
Enable the Tool
2
React to a Busy State
3
Detect Degraded Channels
How It Works
The running gateway registers a live source into the per-turn context;gateway_status resolves it and serializes a snapshot, returning the no-gateway message when nothing is registered.
Core ships only the protocol, the snapshot shape, and the built-in tool; when no source is registered (CLI / one-shot), the tool returns the no-gateway message instead of raising.
Fields Reference
gateway_status() takes no arguments and returns a JSON string serialized from GatewayStatus.as_dict(). Every field defaults to empty so a partial binding is valid.
Example returned JSON:
When It’s Available
gateway_status needs a running bot/gateway to read live self-state; a plain CLI run has nothing to report.
When no gateway is active the tool returns:
snapshot() raises, the tool logs and returns "Error reading gateway status: {e}" — it never raises into the agent turn.
User Interaction Flow
A user in Telegram asks the ops assistant “Are you swamped right now?” The agent callsgateway_status(), sees run: "busy", queued: 3, active_sessions: 12, and replies with a grounded estimate instead of a silent delay.
Common Patterns
Proactive backlog warning
Delivery health check before a critical send
Degraded-channel apology
Best Practices
Use it to warn, not to gate
Use it to warn, not to gate
Report state and continue. Don’t loop until
run == "idle" — that stalls the turn. A single call gives the agent enough to set expectations.Prefer it over polling
Prefer it over polling
One call returns the whole picture — run status, sessions, delivery, and degraded owners. There’s no reason to combine multiple health tools.
Combine with send_message for reliable delivery
Combine with send_message for reliable delivery
Check
delivery.dead_targets and delivery.dlq before sending to sensitive channels, so the agent can warn the user first.Tolerate the no-gateway string in CLI runs
Tolerate the no-gateway string in CLI runs
In tests and one-shot runs the tool returns the no-gateway message. Write instructions that handle that string instead of assuming a JSON snapshot.
Related
Send Message Tool
Deliver a message to a target without waiting for a reply
Ask Conversation Tool
Ask a target and wait for its reply mid-turn
Clarify Tool
Ask the current user for input mid-turn
Messaging Bots
Set up the gateway that makes this tool available

