Skip to content

feat(gateway): a server_config trigger action arms or clears a server's faults - #1009

Draft
cikowski wants to merge 5 commits into
mainfrom
arete/tsk_01M8S4D7EXWE3CRQ1961WP0MKN/fault-row-15-gateway-server-conf
Draft

cikowski wants to merge 5 commits into
mainfrom
arete/tsk_01M8S4D7EXWE3CRQ1961WP0MKN/fault-row-15-gateway-server-conf

Conversation

@cikowski

@cikowski cikowski commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Faults (forced errors, latency) were set once, before the agent starts, so a task could not say "after the first send, mail is down for two hours". A trigger can now call a backing server's advertised config extension (such as urn:agentenv:set-errors/v1) with a server_config action, and a later one clears it with clearing args (error_rate: 0.0).

  • Shape: service (a name, or * for all), uri, templated args, tolerate_unadvertised. Action, state and time triggers, with delay, barrier and unless.
  • Rule: the targets are the server service names (an MCP server before a website of that name), or every backing server for *; no target fails the action. Each target's card is read live when the action fires. A 404, or a card that does not advertise the uri, is skipped when tolerate_unadvertised is set or the target is a website that * reaches, and fails otherwise. Any other card failure (an error status, a timeout, a malformed card) or no endpoint for the uri fails. Otherwise args go to the advertised endpoint: a 2xx reply applies, whatever its body; any other reply fails. Every target is tried; the action fails if any target failed. This is the trigger's own rule; apply_server_config's differs in places.
  • Each server is called at its own address with no control token, never through the gateway's /svc routes, which a bundle's lock closes.
  • Each fire writes a server_config event to the env trajectory. fetch_child_card also leaves out a card that is not a JSON object.

Rollout

The gateway advertises a server_config trigger feature; the client's register_env_triggers refuses such a trigger on a gateway without it. Existing triggers are unchanged. Rollback: revert; a task using the action is then refused at registration.

Validation

Head 3daf9c3a0f643a0122b53c469cba59cfe663860e. 48 new tests:

  • tst/unit/env/gateway/triggers_server_config_socket_test.py: real loopback servers; a notes_save call takes mail down and a time trigger 2h later restores it (sends [ok, fail, fail, ok]), also behind a stand-in guard that 404s every route but /mcp.
  • tst/unit/env/gateway/triggers_server_config_test.py: outcome rules (a 2xx applies whatever its body: [no-content] and [plain-text] fail if the reply is parsed as JSON), failures and their events (a redirected reply fails: [redirected] fails on the old >= 400 check), templating, state, unless, refused shapes.
  • tst/unit/task_step/test_register_env_triggers.py: an older gateway is refused.

With src/ reverted to main 367eeea, 43 of the 48 fail (the other 5 are existing card-omission cases).

Quality bar

Head 3daf9c3a0f643a0122b53c469cba59cfe663860e. Quality profile: rigorous (eng-standards Q1-Q13).

Gate Ran on Result
Local CI (ruff check, unit tier pytest tst/unit packages/agentenv-protocol/tests) 3daf9c3 ruff clean; 23219 passed, 3 failed (the same 3 as the baseline: local environment)
Baseline: same commands on clean origin/main 367eeea ruff clean; 23171 passed, 3 failed (local environment)
Test review: reran the suite and mutated the changed lines dc74fd7; 3daf9c3 changes only a docstring PASS (every mutant named was killed)
Adversarial review: probes for races, crashes and bad input 3daf9c3 PASS; an earlier run's one major, a claim in this description, was fixed by stating the rule above, and its minors are under Known limitations
Conformance review: design note, eng-standards and this description's claims 3daf9c3 PASS
Greptile 3daf9c3 5/5
CI 3daf9c3 33 green, 1 skipped
pr_gate.py check 3daf9c3 every bar met

Relaxations: none.

For the docs

The trigger page should cover the server_config action: its fields (service or *, uri, templated args, tolerate_unadvertised; service and uri are literal; verify, as and to are refused), the rule above (the trigger's own, not apply_server_config's), clearing by args, the server_config trajectory event, and the server_config trigger feature register_env_triggers checks.

Not in this PR

  • reveal_tools in an extension's reply; control tokens for computer children.
  • invoke_extension (the setup step's path) still treats a 3xx reply as applied; a separate change.
  • A release, the worker pin bump, and runs on a hosted env and in a locked bundle.

Known limitations (each has a follow-up):

  • Time triggers that come due in one clock advance fire concurrently, as on main, so an arm and a clear on one server with absolute at marks can apply out of order; anchor a clear on its arm with after:.
  • A strict broadcast that applies on some servers and fails on one leaves those armed, starts no after: clear and fires again on the next provoking call, because dependents resolve only on success, as on main.
  • A card whose extensions is an object or a string reads as not advertising the uri (skipped when lenient), not as malformed.
  • Readability: _configure_server's control flow and its place in Gateway, the args check shared with the tool action, and fetch_child_card logging a non-object card as malformed JSON.

🤖 Generated with Claude Code

Confidence Score: 5/5RetriggerView in Greptile

The PR appears safe to merge, with no new actionable issues in the latest change.

Summary

Adds the server_config trigger action to arm or clear faults on backing servers. The latest change only corrects _configure_server’s docstring; no new actionable issues were found.

  • A trigger can now arm or clear a backing server's faults.

Diagram

sequenceDiagram
    participant T as Trigger engine
    participant G as Gateway
    participant S as Backing server
    T->>G: Run server_config
    G->>S: Read live card
    G->>S: Call advertised extension directly
    S-->>G: HTTP status
    G-->>T: Per-server outcomes
    T->>G: Record server_config event
Loading

Reviews (12) · Last reviewed commit: "docs(gateway): _configure_server states ..." · Reviewed by Greptile

…'s faults

A trigger can now call a backing server's advertised config extension (for
example set-errors/v1 or set-latency/v1) with args, so a call to one tool, a
point in virtual time or a state change can take another server down and a
later trigger can bring it back by sending clearing args.

- server_config action: service (a server's name, or * for every server),
  uri, args (templated like a tool action's), tolerate_unadvertised. Each
  server's outcome (applied, skipped or failed) follows apply_server_config;
  a name the gateway has no server for fails even when tolerated.
- The gateway calls each server at its own address, read from its card, so
  the action still works once a bundle's lock has closed every route but /mcp.
  A broadcast tries every server before the action fails.
- Each fire writes a server_config event to the env trajectory with each
  server's outcome.
- Cards advertise the server_config trigger feature, and
  register_env_triggers refuses an older gateway that lacks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cikowski
cikowski requested a review from a team as a code owner December 4, 2026 19:09
Comment thread src/agent_env/env/gateway/gateway.py Resolved
Comment thread src/agent_env/env/gateway/gateway.py Resolved
cikowski and others added 4 commits December 4, 2026 19:15
…plied

Greptile round 1 on #1009:
- The client does not follow redirects, so a 3xx reply means the config
  handler never ran: any reply but 2xx now fails that server.
- The reply excerpt and detail lengths are named class constants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…E3CRQ1961WP0MKN/fault-row-15-gateway-server-conf
…tatus alone, as now stated and tested

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cikowski
cikowski marked this pull request as draft December 6, 2026 14:22

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant