Repository navigation
feat(core): make codemode agent and llm limits configurable - #67221
kitlangton wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Works as described. On the base branch, a Code Mode agent() child's completion lands in the parent's inbox; with this PR it finishes quietly, and a follow-up sent through a Job still reports back. I checked this by running the new subagent-report test on both branches. The three test files pass (32 tests) and tsc on packages/core is clean.
Public API: adds the config key experimental.codemode_agent_limits with optional positive-integer fields agent_concurrency, agent_total, llm_concurrency and llm_total. This is backwards compatible. Existing configs don't change, but the effective default limits go up from 16/100 to 64/500 for agent() and from 32/500 to 128/2000 for llm().
Blocking: packages/protocol/openapi.json wasn't regenerated. bun run check:generated in packages/protocol fails on this branch ("Generated OpenAPI document is stale") and passes on dev, and CI runs that check. Please run bun run generate there.
Worth trimming: the new limits tests are much larger than what they check (see inline).
This covers the reporting part of #66691 only. compaction-subagents.ts still has the automation-only filter, so finished agent() children still take up subagent slots in compaction checkpoints.
Related: #66691
| subagent_depth: NonNegativeInt.pipe(optional).annotate({ | ||
| description: "Maximum subagent nesting depth. Defaults to 1.", | ||
| }), | ||
| codemode_agent_limits: Schema.Struct({ |
There was a problem hiding this comment.
This new config key is part of the generated OpenAPI document, so packages/protocol/openapi.json needs regenerating. bun run check:generated in packages/protocol fails on this branch and CI runs it. Running bun run generate there should fix it.
| if (!result.ok) expect(result.error.message).toContain("already started 3") | ||
| }) | ||
|
|
||
| test("enforces agent() concurrency cap and shares run state across concurrent first calls", async () => { |
There was a problem hiding this comment.
The limits block adds about 190 lines for a few small behaviours.
- Three tests repeat the same ~20-line
provideServicesetup. A smallrun(script, impl)helper would cut most of that. - The concurrency tests measure overlap with real
Effect.sleepcalls (20–25 ms), which depends on timing. - The schema-bounds test (line 291) mostly checks
PositiveInt, and the "cache-stable" instructions test checks that a pure function returns the same string twice. Both can be dropped.
One total-cap test, one concurrency-cap test and the mergeLimits layering test would cover the change.
7ea7d3e to
7264ebe
Compare
There was a problem hiding this comment.
Neither of my earlier points is fixed in the pushed commit. The only change is that the SubagentReport part was dropped. packages/protocol/openapi.json still isn't regenerated, and bun run check:generated in packages/protocol still fails, which will fail CI. test/codemode/agents.test.ts is unchanged too: it still uses Effect.sleep and has no Deferred gates. The description says both were done, so those changes may not have been pushed.
The two test files pass (19 tests) and tsc on packages/core is clean.
Public API: adds the config key experimental.codemode_agent_limits with optional positive-integer fields agent_concurrency, agent_total, llm_concurrency and llm_total, and raises the default limits. This is backwards compatible.
There was a problem hiding this comment.
Both earlier points are addressed. The OpenAPI document and the client's generated types are regenerated, and the generated-file checks pass in packages/protocol and packages/client. The limits tests are down to three cases that share a run helper, and the concurrency test now uses Deferred gates instead of timed sleeps. I ran the two test files three times and all 15 tests passed each time; tsc on packages/core is clean. Nothing new to raise.
Public API: adds the config key experimental.codemode_agent_limits with optional positive-integer fields agent_concurrency, agent_total, llm_concurrency and llm_total. The OpenAPI spec and the generated client ConfigEntry type gain the same field. Default limits go from 16/100 to 64/500 for agent() and from 32/500 to 128/2000 for llm(). This is backwards compatible.
There was a problem hiding this comment.
The latest commit returns the defaults to 16/100 for agent() and 32/500 for llm(), and the code, schema descriptions, skill text and test all agree. The generated-file checks pass in packages/protocol and packages/client, the two test files pass (15 tests) and tsc on packages/core is clean. Both earlier points (regenerated OpenAPI, trimmed tests) are still addressed. Nothing new to raise.
Public API: adds the config key experimental.codemode_agent_limits with optional positive-integer fields agent_concurrency, agent_total, llm_concurrency and llm_total. The OpenAPI spec and the generated client ConfigEntry type gain the same field. Default behaviour is unchanged, so this is backwards compatible.
Adds experimental.codemode_agent_limits so Code Mode agent() and llm() concurrency and total caps can be configured per user or workspace while keeping built-in defaults unchanged at 16/100 (agent) and 32/500 (llm).
Added by the opencode bot (AI-generated).
Related: #66691
Public API: adds config key experimental.codemode_agent_limits (agent_concurrency, agent_total, llm_concurrency, llm_total) to the schema, OpenAPI spec and client types; defaults unchanged (backwards compatible)