Skip to content

Agent steps need a time limit: one f.agent can spend a flow's whole budget #604

Closed

Description

@khaliqgant

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-repair agent 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.

  1. AgentOptions.timeout?: string | number: same duration syntax as RunOptions.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).
  2. 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 in SURFACE.md whether it throws (and what it throws) or resolves.
  3. Work the agent already committed in the workspace stays there (nothing is reset on timeout).
  4. Replay/resume: a timed-out agent step replays as timed out; it is not re-executed on resume.
  5. Omitting timeout keeps 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.run step.
  • A resume test showing the timed-out step is not re-run.
  • SURFACE.md updated.

Out of scope

Context: cloud#4108 (Garden runs dying on their own budget), agentrelay.com#132 (time-aware generator, the current workaround).

Activity

  1. added
    garden-ready
    on Oct 3, 2026
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

    garden-ready

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions