Skip to content

Make default output paths unique and authoritative across all run modes#227

Open
smithyyang wants to merge 9 commits into
nicobailon:mainfrom
smithyyang:comprehensive-output-runtime-fixes
Open

Make default output paths unique and authoritative across all run modes#227
smithyyang wants to merge 9 commits into
nicobailon:mainfrom
smithyyang:comprehensive-output-runtime-fixes

Conversation

@smithyyang
Copy link
Copy Markdown

Summary

This PR fixes several output-path and UI issues across foreground, async, parallel, and chain subagent execution paths.

It makes runtime output paths authoritative and unique when they come from agent defaults, while preserving exact user-specified output paths.

Fixes

1. Prevent output collisions for default agent outputs

When an agent default output path is used, the runtime now appends a unique suffix:

/tmp/research.md -> /tmp/research_<runId>_<index>.md

This prevents multiple subagents from writing to the same file in parallel/chain runs.

Covered paths:

  • foreground single
  • foreground top-level parallel
  • foreground chain sequential steps
  • foreground chain parallel steps
  • async single
  • async chain
  • async parallel

Explicit user output paths remain exact and are not modified:

subagent({ agent: "researcher", output: "/tmp/custom.md", task: "..." })

2. Fix async parallel index collision

Previously, async parallel default outputs all used index 0, causing two researchers to write to the same file:

/tmp/research_<runId>_0.md
/tmp/research_<runId>_0.md

This PR passes the real flat step index, producing:

/tmp/research_<runId>_0.md
/tmp/research_<runId>_1.md

3. Fix async single default-output suffixing

Async single runs pre-normalized the output before calling executeAsyncSingle, so the lower layer could not tell whether the path came from an agent default or an explicit user override.

This PR adds an outputFromAgentDefault flag so async single can suffix default outputs correctly without changing explicit outputs.

4. Make runtime output paths authoritative in prompts

Agent prompts may mention static filenames such as research.md, context.md, or plan.md. Runtime-generated paths must override these static filenames.

This PR strengthens task output instructions from:

**Output:** Write your findings to: /tmp/research_xxx_0.md

to:

**Output:**
Write your findings to exactly this path: /tmp/research_xxx_0.md
This path is authoritative for this run.
Ignore any other filename mentioned elsewhere, including filenames in the base agent prompt, system prompt, or task instructions.

It also injects the same runtime output override into the child system prompt, so the system prompt and task prompt agree on the authoritative output path.

5. Disable default progress files for built-in writer agents

The built-in researcher, scout, and worker agents now set:

defaultProgress: false

This avoids automatic progress file creation unless the caller explicitly asks for progress.

6. Disable chain clarify UI by default

Sequential foreground chains previously opened the clarify UI by default. This PR changes chain clarify behavior so the UI only opens when explicitly requested:

clarify: true

Default behavior now matches single/parallel runs: execute directly unless clarify is requested.

7. Show model badge in compact multi-result view

Compact multi-result rendering now includes the model/thinking badge for each result row.

Validation

Manual validation performed locally:

  • foreground parallel with 3 researchers created unique files:
    • /tmp/research_<runId>_0.md
    • /tmp/research_<runId>_1.md
    • /tmp/research_<runId>_2.md
  • async parallel with 2 researchers now injects and saves to _0.md and _1.md respectively
  • async single now injects and saves to _0.md
  • foreground chain no longer opens clarify UI by default
  • foreground chain step 1 wrote to _0.md, and step 2 received _1.md in its task instructions
  • task prompt contains authoritative output instruction
  • system prompt injection path is wired through foreground runSync and async step construction
  • TypeScript syntax checks passed for changed files

Notes

This PR intentionally preserves backwards compatibility:

  • explicit output paths are used exactly as provided
  • output: false disables output
  • output: true means “use the agent default” and receives the runtime suffix

When no explicit `output` is passed in the subagent call and the
output comes from the agent config default (e.g. `output: /tmp/research.md`),
the framework now appends `_<runId>_<index>` to prevent collisions in
parallel execution and avoid hardcoded-path confusion.

- Foreground single: suffix added when `params.output` is undefined
- Foreground parallel: suffix added per task when no task-level override
- Async single + async chain: same logic
- Progress tracks alongside output in the same directory

Progress path is `.progress_<runId>/progress.md` (same directory);
a follow-up could use `progress_<runId>.md` for consistency.

Related: nicobailon#220, nicobailon#223, nicobailon#224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant