Files
Arvin Xu f7f688bfa0 ⚡️ perf(agent): always inline agent steps in queue mode (#19531)
* ⚡️ perf(agent): lower the inline step start deadline to 300s

The deadline only decides whether a step may start; what keeps the
invocation alive is the headroom between it and the route's 600s
`maxDuration`. 150s of headroom was not enough in production. LLM step
length varies a lot by model, and for one family p99 is ~317s with a
~439s max. Under 450s, steps started before the deadline were observed
finishing within seconds of the kill.

300s doubles the headroom. It gives up a little of the round-trip saving
on very long operations in exchange for far fewer killed steps. A killed
step is not lost, since it resumes from the parked envelope, but it is
paid for twice.

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

* 🔥 refactor(agent): remove the inline_agent_steps feature flag

The inline step loop now always runs in the queue worker. The flag existed to
limit the blast radius of steps killed at `maxDuration`, and that blast radius
turned out to be cost rather than correctness. A killed step resumes from its
parked envelope and finishes, and the only loss is paying for that LLM call
twice.

Removed:
- `inline_agent_steps` from `FeatureFlagsSchema`, its default, and the
  `enableInlineAgentSteps` field on `IFeatureFlagsState`
- `inlineStepsGate.ts`, along with the per-invocation RuntimeConfig lookup in
  `runStep`
- the two handler tests that only covered the flag-off path

Parked-envelope recovery was never gated on the flag, so nothing changes for
operations that are already mid-loop.

The published snapshot still contains the `inline_agent_steps` key. The
schema is a plain `z.object`, so the key is stripped as unknown instead of
failing validation. This was checked by parsing the live production snapshot
against the new schema: every other flag survives.

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

* Update runStep.ts

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 22:32:55 +08:00
..