Skip to content

feat(dynamic-workflow): run subagents on a chosen model - #30

Merged
elkaix merged 3 commits into
mainfrom
feat/dynamic-workflow-subagent-model
Aug 6, 2026
Merged

feat(dynamic-workflow): run subagents on a chosen model#30
elkaix merged 3 commits into
mainfrom
feat/dynamic-workflow-subagent-model

Conversation

@elkaix

@elkaix elkaix commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Related Issue

No issue — problem described below.

Problem

Every subagent in a Dynamic Workflow ran on whatever model the calling agent
was using. A workflow that fans 128 children out over mechanical work — reading
files, applying a mechanical edit, running a check — paid the orchestrator's
model for all of it, and there was no way to say "plan here, implement there"
without editing an agent profile up front.

The provider layer already supported this: a model alias resolves to its own
provider per agent, and configureChild already honoured profile.model /
profile.effort (kept across resume by #28). The routing decision just had no
way to reach a single run.

What changed

DynamicWorkflow accepts model and effort. Both apply to every subagent in
the call and travel on QueuedSubagentTask through SubagentBatch into
RunSubagentOptions, where the existing option → profile → parent precedence
resolves them, so the choice also survives resume and retry. An alias the
provider cannot resolve falls back to the calling agent's model instead of
failing at generate time.

/workflow model <alias> stores the choice for the session; /workflow model
reports it and /workflow model off clears it. The alias reaches the run as an
instruction on the task prompt rather than a hard override, so the agent can
still pick something else when the work plainly calls for it — the same shape
as the existing Dynamic Workflow mode reminders.

/workflow model deepseek-v4
/workflow audit every route handler under src/routes/ for missing auth
→ orchestrator stays on the session model, all 128 children run on deepseek-v4

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Summary by CodeRabbit

  • New Features

    • Configure a model and reasoning effort for all Dynamic Workflow subagents.
    • Use /workflow model <alias> to view, select, or clear the session’s subagent model.
    • Added autocomplete support for the new workflow model command.
  • Documentation

    • Updated Dynamic Workflow and slash-command documentation with model and effort configuration details.
  • Bug Fixes

    • Ensured selected model and reasoning settings apply consistently to spawned and resumed workflow tasks.

Let a workflow hand mechanical work to a cheaper or faster model while
the orchestrating agent stays where it is.

DynamicWorkflow accepts model and effort, carried on QueuedSubagentTask
through SubagentBatch into RunSubagentOptions, where the existing
option-then-profile-then-parent precedence resolves them. /workflow model
<alias> stores the choice for the session and passes it to the task as an
instruction, so the agent can still pick something else when the work
plainly calls for it.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 68a04f63-f559-47b4-bfc4-bfb9c9b9b634

📥 Commits

Reviewing files that changed from the base of the PR and between f7f731e and 3758a37.

📒 Files selected for processing (4)
  • apps/pythinker-code/src/tui/commands/dynamic-workflow.ts
  • apps/pythinker-code/test/tui/commands/dynamic-workflow.test.ts
  • packages/agent-core/src/tools/builtin/collaboration/dynamic-workflow.md
  • packages/agent-core/test/session/subagent-batch.test.ts
📝 Walkthrough

Walkthrough

DynamicWorkflow now accepts optional subagent model and effort settings. Queued tasks propagate these settings to subagent runs. The TUI adds /workflow model for session-scoped model selection.

Changes

Dynamic Workflow model configuration

Layer / File(s) Summary
Workflow configuration and subagent propagation
packages/agent-core/src/tools/builtin/collaboration/dynamic-workflow.ts, packages/agent-core/src/session/subagent-batch.ts, packages/agent-core/test/session/*, packages/agent-core/test/tools/*, docs/reference/tools.md, packages/agent-core/src/tools/builtin/collaboration/dynamic-workflow.md
DynamicWorkflow accepts optional model and effort values. Queued tasks pass the normalized settings to spawned, resumed, and retried subagents. Tests verify propagation and schema ordering.
TUI model selection and prompt handling
apps/pythinker-code/src/tui/commands/dynamic-workflow.ts, apps/pythinker-code/src/tui/types.ts, apps/pythinker-code/test/tui/commands/dynamic-workflow.test.ts
/workflow model reports, sets, and clears the session model preference. Configured preferences are added to subsequent task prompts.
Command discoverability and documentation
apps/pythinker-code/src/tui/commands/registry.ts, apps/pythinker-code/test/tui/commands/registry.test.ts, docs/reference/slash-commands.md, .changeset/dynamic-workflow-subagent-model.md
Command completion and descriptions include model. Reference documentation and the changeset describe the new settings.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses a valid conventional-commit prefix, imperative wording, stays within 72 characters, and accurately describes the main change.
Description check ✅ Passed The description includes all required sections, explains the problem and implementation, and confirms tests, changeset, and documentation updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 5, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@pythoughts/pythinker-code@3758a37
npx https://pkg.pr.new/@pythoughts/pythinker-code@3758a37

commit: 3758a37

@elkaix

elkaix commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/pythinker-code/src/tui/commands/dynamic-workflow.ts`:
- Line 114: Update the regular expression in the command parser to include the
Unicode (`u`) flag, preserving its existing case-insensitive matching and
capture behavior so it satisfies Oxlint’s require-unicode-regexp rule.

In `@apps/pythinker-code/test/tui/commands/dynamic-workflow.test.ts`:
- Around line 356-359: Update the test covering handleDynamicWorkflowCommand
with 'model off' to also assert that host.state.appState.dynamicWorkflowModel is
undefined after the command completes, while retaining the existing
status-message assertion.

In `@packages/agent-core/src/tools/builtin/collaboration/dynamic-workflow.md`:
- Line 7: Update the workflow documentation describing model fallback behavior
to include all outcomes: fallback to the calling agent when no model is
configured by the subagent profile, and fallback behavior when the configured
model alias cannot be resolved. Keep the existing subagent-profile fallback
guidance and ensure the documented rules apply to every subagent in the call.

In `@packages/agent-core/test/session/subagent-batch.test.ts`:
- Around line 672-685: Extend the existing resume and rate-limit retry test
cases alongside the spawn-task coverage to assert that every recorded
RunSubagentOptions attempt preserves both modelAlias and thinkingLevel. Use the
existing attempt collections and expected routed-task values, while keeping the
current completion and retry behavior unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a73b5b13-e3c9-49b2-a1c1-ff1638d0f432

📥 Commits

Reviewing files that changed from the base of the PR and between cf5b6b1 and f7f731e.

📒 Files selected for processing (13)
  • .changeset/dynamic-workflow-subagent-model.md
  • apps/pythinker-code/src/tui/commands/dynamic-workflow.ts
  • apps/pythinker-code/src/tui/commands/registry.ts
  • apps/pythinker-code/src/tui/types.ts
  • apps/pythinker-code/test/tui/commands/dynamic-workflow.test.ts
  • apps/pythinker-code/test/tui/commands/registry.test.ts
  • docs/reference/slash-commands.md
  • docs/reference/tools.md
  • packages/agent-core/src/session/subagent-batch.ts
  • packages/agent-core/src/tools/builtin/collaboration/dynamic-workflow.md
  • packages/agent-core/src/tools/builtin/collaboration/dynamic-workflow.ts
  • packages/agent-core/test/session/subagent-batch.test.ts
  • packages/agent-core/test/tools/builtin-current.test.ts

Comment thread apps/pythinker-code/src/tui/commands/dynamic-workflow.ts Outdated
Comment thread apps/pythinker-code/test/tui/commands/dynamic-workflow.test.ts
Comment thread packages/agent-core/src/tools/builtin/collaboration/dynamic-workflow.md Outdated
Comment thread packages/agent-core/test/session/subagent-batch.test.ts Outdated
elkaix added 2 commits August 5, 2026 20:32
Add the Unicode flag to the /workflow model parser so it satisfies the
repo's require-unicode-regexp rule. Assert the cleared state in the
model-preference test instead of only its status message, and extend the
batch propagation test to the resume and retry launch paths. Document the
fallback to the calling agent's model and the unresolved-alias fallback in
the tool description, not only in the reference docs.
An alias the engine cannot resolve falls back to the session model when the
subagent spawns, so accepting one reported a routing that never happened.
Check it against the configured models and show an error instead.
@elkaix
elkaix merged commit 463b176 into main Aug 6, 2026
11 checks passed
@elkaix
elkaix deleted the feat/dynamic-workflow-subagent-model branch August 6, 2026 01:20
elkaix added a commit that referenced this pull request Aug 7, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @pythoughts/pythinker-code@0.10.0

### Minor Changes

- [#30](#30)
[`463b176`](463b176)
- Let a Dynamic Workflow run its subagents on a different model than the
agent orchestrating them. `DynamicWorkflow` accepts `model` and `effort`
for every subagent in the call, and `/workflow model <alias>` sets that
model for the session so an expensive orchestrator can hand mechanical
work to a cheaper or faster one.

### Patch Changes

- [#28](#28)
[`cf5b6b1`](cf5b6b1)
- Keep a subagent on the model and effort its profile assigns when the
subagent is resumed or retried, instead of reverting it to the main
agent's model.

- [#31](#31)
[`e5e9de4`](e5e9de4)
- Brighten the periwinkle accent in the VS Code extension's dark theme
so inline code in chat is easier to read.

- [#31](#31)
[`e5e9de4`](e5e9de4)
- Let `/yolo` and `/auto` be used in the VS Code extension before the
first message is sent — the request now applies to the session that chat
opens next instead of failing with "Could not change the permission
mode."

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: M Elkholy <melkholy@techmatrix.com>
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