Repository navigation
Description
Problem
f.agent(...) has no time limit. RunOptions has timeout (a lease, default 30s, max 15m), but AgentOptions (packages/surface/src/context.ts) has none, so an agent step runs until it finishes or the flow's header budget.wallclock is spent.
Measured on generated Software Garden runs (AgentWorkforce/cloud#4108):
- a
check-repairagent ran 44m09s, 303 turns, $26.57 (run c3e3bb50), above the flow's declared$25; - another ran 37m18s (run bda21b91), and that run then hit its 2h header before it could publish passing work.
Because the header is only checked between steps, one long agent can spend the whole remaining budget, and then no step can run, not even the push that would keep the work.
The Garden generator now works around this (agentrelay.com#132): it reads the clock before each optional agent and skips it if its allowance plus publishing no longer fits. But those allowances are estimates the agent is free to overrun; nothing stops a 45-minute "allowance" from taking 90.
Ask
Add a time limit to agent steps.
AgentOptions.timeout?: string | number: same duration syntax asRunOptions.timeout. Pick and document a maximum that real agent work fits under (repairs measured up to 44m; 60m seems a reasonable ceiling, but state the reason for whatever you choose).- When the limit is reached, the agent's CLI process is stopped and the step ends with a distinct, journaled outcome (e.g.
timeout) that the flow body can catch and continue from: a timed-out repair should let the flow go on to publish what it has, not end the run. Say clearly inSURFACE.mdwhether it throws (and what it throws) or resolves. - Work the agent already committed in the workspace stays there (nothing is reset on timeout).
- Replay/resume: a timed-out agent step replays as timed out; it is not re-executed on resume.
- Omitting
timeoutkeeps today's behavior (no per-step limit), so existing flows are unchanged.
Acceptance
- Unit tests for option validation (bad duration, over max) and lowering.
- A runtime test where an agent that would run forever is stopped at its limit, the outcome is journaled as a timeout, and the flow body catches it and runs a following
f.runstep. - A resume test showing the timed-out step is not re-run.
SURFACE.mdupdated.
Out of scope
- relayflows-agent-cli-v1 wrappers have an unraisable 300s execution cap, so no wrapper can do real agent work #525 (the 300s cap inside
relayflows-agent-cli-v1wrappers) is a different limit, though related; don't fold it in unless the fix naturally covers it. - Enforcing
budget.dollars. - Changing the Garden generator to use the new option: that is a follow-up in agentrelay.com once this ships in a release.
Context: cloud#4108 (Garden runs dying on their own budget), agentrelay.com#132 (time-aware generator, the current workaround).
Activity