Repository navigation
Conversation
There was a problem hiding this comment.
The test does what it says. It uses the real plugin supervisor, and tester.md reaches the catalog only through the config watcher and reload. To confirm, I disabled the agent plugin's reload in src/config/plugin/agent.ts, and the new case failed. With the change, bun test test/tool-subagent.test.ts passes (12/12, and the new case passed 5 times in a row at ~0.5s), and bun run typecheck passes in packages/core.
The public API is unchanged; only a test file changes.
One thing worth fixing: when the reload is broken, the test fails at bun's 5s per-test timeout instead of at an assertion (see inline).
Related: #57138
| ), | ||
| ) | ||
| const locationAgents = yield* Agent.Service.pipe(Effect.provide(locations.get(parent.location))) | ||
| for (let attempt = 0; attempt < 100; attempt++) { |
There was a problem hiding this comment.
This loop never fails by itself, and 100 × 50ms equals bun's default 5000ms test timeout. When I turned off the agent plugin's reload, the test ended as (fail) … [5000.03ms], a bare timeout, and never got to the assertions below. A bounded wait that fails clearly would be easier to diagnose, for example locationAgents.get(id).pipe(Effect.repeat({ until: (agent) => agent !== undefined, schedule: Schedule.spaced("50 millis") }), Effect.timeout("2 seconds")). The pendingBackground wait earlier in this file does something similar.
60314f8 to
3d4f117
Compare
|
Answering the question in the review — "if your test passes on current It was fixed, the day after the reproduction in #57138. The bot's repro there was on The mechanism fits the report exactly. Before that fix, Two other things I checked while narrowing it, so the record is complete:
I've also taken the review's other point: the wait budget now leaves the failure on the assertion rather than on bun's per-test timeout, and the case carries a 30 s timeout of its own so a loaded machine cannot trip it. |
The subagent tests inject agents straight into the location's Agent.Service, so the config agent plugin never runs against a session's location. This covers an agent file that appears after the session started: the location catalog sees it and the subagent tool can run it. The watcher is real, so the wait budget leaves the failure on the assertion rather than on bun's per-test timeout. Fixes anomalyco#57853
3d4f117 to
45bd734
Compare
Issue for this PR
Fixes #57853
Type of change
What does this PR do?
Covers an agent file that appears after the session started, at the layer #57138 is actually about.
The subagent tests inject agents straight into the location's
Agent.Service, so the config agent plugin never runs against a session's location. This case creates a session in a temp project with an empty.opencode/agents/, writestester.mdafterwards, and asserts that the location's agent catalog sees it (mode: subagent) and thatsubagent({ agent: "tester" })runs it to completion.It passes on
dev: the chain session → location → config agent plugin → watcher → agent catalog → subagent tool → child session works for an agent that appears mid-session. So this is a guard, not a fix — it fails if that ever stops being true.Why it passes, given the report in #57138: the bug was fixed by #57416 (keep locations with running sessions or background jobs), merged 2026-10-20 — one day after the reproduction on
86ac38a(2026-10-19) that was posted there. Before that fix, a location whose TTL expired could be invalidated while a session was waiting on a question or had a background job (neither is inexecution.active), so the session's agent catalog went stale andsubagentansweredUnknown agent: tester.How did you verify your code works?
bun test test/tool-subagent.test.tsfrompackages/core— 12 pass, 0 fail.Screenshots / recordings
Not a UI change.
Checklist