Skip to content

feat(agent): add chain mode with {previous} placeholder support#53

Open
anh-chu wants to merge 1 commit into
tintinweb:masterfrom
anh-chu:feat/chain-mode
Open

feat(agent): add chain mode with {previous} placeholder support#53
anh-chu wants to merge 1 commit into
tintinweb:masterfrom
anh-chu:feat/chain-mode

Conversation

@anh-chu

@anh-chu anh-chu commented May 8, 2026

Copy link
Copy Markdown

Adds a chain parameter to the Agent tool that runs multiple agents sequentially, with each step receiving the previous step's output via a {previous} placeholder.

Usage:

Agent({
  chain: [
    { subagent_type: "Explore", prompt: "Find all auth-related files" },
    { subagent_type: "Plan", prompt: "Using: {previous}, design a JWT migration" },
    { subagent_type: "worker", prompt: "Implement: {previous}" },
  ]
})

Changes: 1 file, +228 lines in src/index.ts

  • chain TypeBox parameter in Agent tool schema (Type.Optional Array, min 2 items)
  • executeChain() function: sequential spawnAndWait, {previous} substitution, per-step error handling, abort support
  • Summary output: "Chain completed in Xms (N steps)" with each step's result

When chain is provided, the single-agent path is skipped entirely. Chain steps inherit top-level params (model, thinking, isolation) as defaults.

@anh-chu

anh-chu commented May 8, 2026

Copy link
Copy Markdown
Author

Just to clarify, this means that users can prompt something like:
explore, then plan -> review on plan, then implement
Which would result in a streamlined E2E flow where each agent pipes their output to the next directly, avoiding polluting the main agent's context.

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