AI agents you can trust in production.
Agents call models in loops and use tools with real side effects. Worksi traces every run, catches the ways agents fail, and gives operators the brakes.
- workflow_runlead-qualificationtwo agents, one run
two agents, one run
- agent_stepresearchresearch-agent
research-agent
- tool_callweb_lookupdiscovered, never registered
discovered, never registered
- tool_callcrm_lookupcrm · data source
crm · data source
- llm_callgpt-4o-minicompany profile summary
company profile summary
- agent_stepscorescoring-agent
scoring-agent
- llm_callgpt-5-miniscore against the rubric
score against the rubric
A looping agent, step by step.
A knowledge-base search comes back empty and the agent sends the same prompt again, paying for every turn. This is how Worksi records it, flags it, explains it and stops it.
The readouts follow the agent-loop incident of the built‑in demo organization. Detector rules are the product defaults.
- 01
Six identical prompts
search_kbfound no articles, and resolver-agent sent gpt-5 the same prompt six times. The SDK records the step and the tool, the gateway every model call.support-ticket-resolution · the looping steps - workflow_runsupport-ticket-resolutionone run, two of its steps
one run, two of its steps
- agent_stepresearchresolver-agent
resolver-agent
- tool_callsearch_kb · emptykb-vector-store · 0 articles
kb-vector-store · 0 articles
- agent_stepdraft_replyresolver-agent
resolver-agent
- llm_callsame prompt · 1 of 6chat.completions gpt-5
chat.completions gpt-5
- llm_callsame prompt · 2 of 6chat.completions gpt-5
chat.completions gpt-5
- llm_callsame prompt · 3 of 6chat.completions gpt-5
chat.completions gpt-5
- llm_callsame prompt · 4 of 6chat.completions gpt-5
chat.completions gpt-5
- llm_callsame prompt · 5 of 6chat.completions gpt-5
chat.completions gpt-5
- llm_callsame prompt · 6 of 6chat.completions gpt-5
chat.completions gpt-5
- 02
Flagged on the fourth send
agent_loopfires when one run sends the same prompt four times. In our benchmark the incident opened 1.9 s after the looping call (measured — how we measured time to detect).Incident · detector - detector
- agent_loop
- rule
- same prompt 4× in one run
- seen
- 6× the same prompt hash
- severity
- high, critical in production
- 03
What the incident carries
The incident arrives with its evidence: the repeated call, the identical prompt and the empty search that started the loop.Incident · evidence - ev-1
- repeated gpt-5 call
- ev-2
- identical prompt repeated 6×
- ev-3
- search_kb returned no articles
- finding
- step count 2× a healthy run
- 04
The next call gets a 423
Worksi suggests stopping the run or pausing the agent. Once it is paused, its next call is refused at the gateway, before your provider sees it.ResponseHTTP/1.1 423 Locked{ "error": { "message": "agent \"resolver-agent\" is paused", "type": "invalid_request_error", "code": "agent_paused", "param": null, "aiw_request_id": "req_…" }}Example response. The body format is the gateway’s.
What else watches your agents.
Five of the eleven built‑in detectors, with the conditions they fire on.
| Detector | Fires when |
|---|---|
Agent loopagent_loop | An agent repeats an identical prompt, or exceeds its step limit, in one run |
Repeated tool callrepeated_tool_call | The same tool is called with the same arguments again and again in one run |
Tool failuretool_failure | A tool keeps failing, or a run ends in error at a tool call |
Stuck workflowstuck_workflow | A run started but never finished within the workflow’s threshold |
Cost anomalycost_anomaly | Cost per request jumps versus the agent’s 7-day baseline, or a run exceeds its cost limit |
Wrap the run, its steps and its tools.
The gateway alone sees every model call and enforces pause and stop. The SDK adds the run, its steps and its tools, so a loop is caught with its context.
Pro fits most agent teams: 1M gateway requests and 10M spans a month, 30‑day retention, approvals. $49 / month.
SDK packages are distributed by Worksi. Request access. Any OpenAI or Anthropic SDK works with the gateway without them.
import osfrom openai import APIStatusError, OpenAI client = OpenAI( base_url="https://gateway.worksi.ai/v1", api_key=os.environ["AIW_API_KEY"], default_headers={"X-AIW-Agent": "resolver-agent"},) def draft_reply(run_id: str, history: list) -> str | None: try: reply = client.chat.completions.create( model="gpt-5", messages=history, # ties every call of the run together extra_headers={"X-AIW-Run-Id": run_id}, ) except APIStatusError as error: # 423 agent_paused or 409 run_stopped: hand over if error.status_code in (409, 423): return None raise return reply.choices[0].message.contentfrom aiworkforce import AIW, AgentPausedError, RunStoppedError aiw = AIW(service="resolver-agent")client = aiw.openai() def resolve(ticket: Ticket) -> None: with aiw.run("support-ticket-resolution", agent="resolver-agent") as run: with aiw.tool("search_kb", args={"q": ticket.subject}, data_source="kb-vector-store") as t: articles = search_kb(ticket.subject) t.set_result({"articles": len(articles)}) try: with aiw.step("draft_reply"): client.chat.completions.create( model="gpt-5", messages=prompt(ticket, articles), ) except (AgentPausedError, RunStoppedError): # paused or stopped from the console return hand_over(ticket) run.outcome("ticket_resolved", success=True)Give your agents a pause button.
Name the agent and the run on every call. When someone pauses the agent, its next call gets 423 and never reaches your provider.
- 3‑day trial with Pro features, no card.
Keep readingSDKsMCPIncidents & diagnosis
curl https://gateway.worksi.ai/v1/chat/completions \ -H "Authorization: Bearer $AIW_API_KEY" \ -H "X-AIW-Agent: resolver-agent" \ -H "X-AIW-Run-Id: $RUN_ID" \ -H "Content-Type: application/json" \ -d '{"model": "gpt-5-mini", "messages": [{"role": "user", "content": "Hi"}]}' # a paused agent gets 423 agent_paused