maxTurns

Hard limit on model+tool iterations per invocation. Default 10. Set to 5-8 for high-volume paths — a runaway loop can burn dollars fast.

RuntimeConfig cfg = RuntimeConfig.builder()
    .maxTurns(8)
    .modelTimeout(Duration.ofSeconds(20))
    .toolTimeout(Duration.ofSeconds(10))
    .build();
runtime = AgentRuntime.create(cfg);
Advertisement

modelTimeout + toolTimeout

Kills the model call or tool call if it hasn't returned. Defaults are 30s and 30s — most production paths want 15-20s.

Advertisement

contextTokenLimit

Runtime-side cap on prompt size. Prevents accidentally sending a 100K token prompt to a model that only accepts 32K. Set to slightly below the model's actual limit.