Skip to content

Support thinking levels for subagent profiles#60

Merged
Waishnav merged 6 commits into
mainfrom
codex/subagent-thinking-effort
Jul 5, 2026
Merged

Support thinking levels for subagent profiles#60
Waishnav merged 6 commits into
mainfrom
codex/subagent-thinking-effort

Conversation

@Waishnav

@Waishnav Waishnav commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • add optional thinking frontmatter and CLI override for subagent profiles
  • persist and expose thinking levels in subagent sessions and workspace profile summaries
  • pass thinking through to Codex, Claude, Pi, OpenCode, and ACP providers

Validation

  • npm run typecheck
  • npm test

Summary by CodeRabbit

  • New Features
    • Added optional agent “thinking” levels across profile frontmatter, open_workspace catalogs, and devspace agents run via --thinking (including override behavior).
    • Thinking is now included in agent availability/listing and devspace agents show output.
  • Bug Fixes
    • Thinking is persisted and consistently applied across local agent session create, update, and resume flows, including forwarding to supported provider runtimes.
  • Documentation
    • Updated the profile schema and guidance for selecting optional thinking levels in workflows.
  • Tests
    • Extended CLI/profile/runtime and provider-adapter test coverage to validate parsing, persistence, and rendering.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c5a74b1-3daa-404d-b3a5-1009fa8ce995

📥 Commits

Reviewing files that changed from the base of the PR and between 74b8c22 and b34f540.

📒 Files selected for processing (4)
  • docs/agent-profile-schema.md
  • skills/subagent-delegation/SKILL.md
  • src/local-agent-adapters.test.ts
  • src/local-agent-store.test.ts
✅ Files skipped from review due to trivial changes (2)
  • docs/agent-profile-schema.md
  • skills/subagent-delegation/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/local-agent-store.test.ts
  • src/local-agent-adapters.test.ts

📝 Walkthrough

Walkthrough

Adds an optional thinking field across agent profile handling, CLI target resolution, storage, runtime execution, provider adapters, server output, and related docs/tests.

Changes

Thinking Level Feature

Layer / File(s) Summary
Profile docs and examples
docs/agent-profile-schema.md, docs/chatgpt-coding-workflow.md, docs/configuration.md, examples/agents/*.md, skills/subagent-delegation/SKILL.md
Docs, examples, and guidance describe thinking in agent profiles and open_workspace output.
Profile schema and parsing
src/local-agent-profiles.ts, src/local-agent-profiles.test.ts
LocalAgentProfile and its summary include thinking, which is parsed from frontmatter and covered by tests.
CLI arg parsing and target resolution
src/local-agent-targets.ts, src/local-agent-targets.test.ts
--thinking is parsed and resolved through profile/provider targets with override support and test coverage.
Database schema and store persistence
src/db/schema.ts, src/db/migrations.ts, src/local-agent-store.ts, src/local-agent-store.test.ts
thinking is added to the local agent session schema, migration, store mapping, and persistence tests.
CLI run and listing wiring
src/cli.ts, src/cli.test.ts
devspace agents run stores and forwards thinking, and agent listings render it in output.
Codex runtime reasoning effort mapping
src/local-agent-runtime.ts, src/local-agent-runtime.test.ts
thinking maps to Codex SDK modelReasoningEffort in thread options and is asserted in runtime tests.
Provider adapter thinking propagation
src/local-agent-adapters.ts, src/local-agent-adapters.test.ts
Claude, Pi, Opencode, and ACP adapters forward thinking, including ACP session config updates via new resolver helpers.
Server output
src/server.ts
Visible agent formatting and the workspace output schema now include thinking.

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

Sequence Diagram(s)

sequenceDiagram
  participant CLI as devspace agents run
  participant Targets as resolveLocalAgentTarget
  participant Store as LocalAgentStore
  participant Runtime as LocalAgentRuntime
  participant Adapter as LocalAgentAdapter
  participant Provider as Provider runtime

  CLI->>Targets: parse --thinking and resolve target
  Targets-->>CLI: thinking value
  CLI->>Store: create/update session with thinking
  Store-->>CLI: persisted record
  CLI->>Runtime: runLocalAgentProvider(thinking)
  Runtime->>Adapter: pass modelReasoningEffort / provider option
  Adapter->>Provider: apply thinking setting
  Provider-->>Adapter: run result
  Adapter-->>Runtime: provider response
  Runtime-->>CLI: execution output
Loading

Poem

A bunny taps the keys tonight,
With thinking set to guide the light.
Through profiles, stores, and runs it hops,
Until each agent neatly stops.
High or medium, deep or bright,
This rabbit likes its reasoning right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding thinking-level support for subagent profiles.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/subagent-thinking-effort

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

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/local-agent-runtime.ts (1)

57-65: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Validate thinking before passing it to Codex.

input.thinking is an untyped string here, but ModelReasoningEffort only allows minimal, low, medium, high, and xhigh. Reject unsupported values up front so typos or provider-specific values like max fail with a clear DevSpace error instead of surfacing later from the SDK.

🤖 Prompt for 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.

In `@src/local-agent-runtime.ts` around lines 57 - 65, `threadOptionsFor` is
passing the untyped `input.thinking` straight into `modelReasoningEffort`, so
invalid values can reach Codex unnoticed. Add upfront validation in
`threadOptionsFor` (or a small helper it calls) to only accept the allowed
`ModelReasoningEffort` values: minimal, low, medium, high, and xhigh. If
`input.thinking` is anything else, reject it with a clear DevSpace error before
building the `ThreadOptions`, so bad inputs fail immediately instead of later in
the SDK.
🧹 Nitpick comments (3)
src/local-agent-store.test.ts (1)

19-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider covering update() persistence of thinking too.

This only verifies thinking round-trips through create()/get(). The update() method has its own separate SQL statement (src/local-agent-store.ts lines 165-194) with independent column ordering/placeholder counts, so a regression there (e.g., a misplaced ?) wouldn't be caught by this test alone.

♻️ Suggested addition
   assert.equal(store.get(created.id)?.thinking, "high");
+
+  const updated = store.update(created.id, { thinking: "medium" });
+  assert.equal(updated.thinking, "medium");
+  assert.equal(store.get(created.id)?.thinking, "medium");
🤖 Prompt for 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.

In `@src/local-agent-store.test.ts` around lines 19 - 24, The current test only
covers `create()`/`get()` for `thinking`, so it won’t catch regressions in
`LocalAgentStore.update()`’s separate SQL path. Extend
`src/local-agent-store.test.ts` to update an existing agent via `update()` and
then assert the persisted `thinking` value is returned by `get()`/readback,
using the `LocalAgentStore` methods and `created.id` to verify the update
round-trips correctly.
skills/subagent-delegation/SKILL.md (1)

51-62: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider documenting that valid --thinking levels are provider-specific.

The doc doesn't mention that accepted <level> values differ per provider (e.g. Codex's minimal/low/medium/high/xhigh vs. Claude's low/medium/high/max, ACP's dynamically-discovered options). Given the underlying code casts thinking without cross-provider validation for Codex/Claude (see src/local-agent-runtime.ts and src/local-agent-adapters.ts), an agent following this doc could pass an invalid level for the chosen provider and only find out via a provider-side error.

🤖 Prompt for 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.

In `@skills/subagent-delegation/SKILL.md` around lines 51 - 62, Clarify that the
accepted values for the `--thinking` flag are provider-specific and may differ
between Codex, Claude, and ACP. Update the guidance around `devspace agents run`
in SKILL.md to mention that users must choose a level supported by the selected
provider, and reference the `--thinking` option along with the relevant
runtime/adapters behavior in `src/local-agent-runtime.ts` and
`src/local-agent-adapters.ts` so the documentation makes this constraint
explicit.
src/local-agent-adapters.test.ts (1)

11-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing error-path coverage for resolveAcpThinkingConfigUpdate.

Tests cover the two valid-mapping cases and one "unsupported value" throw, but not the "session did not return session metadata", "session did not return a session id", or "ACP server does not expose a thinking option" branches. Since this helper is now exported and used by both the cursor and copilot adapters, covering those error paths would guard against regressions.

Also applies to: 31-93

🤖 Prompt for 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.

In `@src/local-agent-adapters.test.ts` at line 11, Add missing negative-path tests
for resolveAcpThinkingConfigUpdate in local-agent-adapters.test.ts: the current
coverage only verifies valid mappings and one unsupported-value throw, but it
should also assert the branches where session metadata is absent, the session id
is missing, and the ACP server does not expose a thinking option. Reuse
resolveAcpThinkingConfigUpdate directly in the test cases and ensure the cursor
and copilot adapter scenarios are represented so these exported helper error
paths stay covered.
🤖 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 `@src/local-agent-adapters.ts`:
- Line 4: Validate input.thinking in local-agent-adapters before forwarding it
to Claude, since the current cast can let unsupported values from profiles or
CLI reach the SDK. Use the same allowed-options check ACP uses for the session,
and only pass through a supported EffortLevel in the local adapter path. Locate
this in the code that imports EffortLevel and builds the Claude request payload,
ensuring invalid thinking values are rejected or omitted before the SDK call.

---

Outside diff comments:
In `@src/local-agent-runtime.ts`:
- Around line 57-65: `threadOptionsFor` is passing the untyped `input.thinking`
straight into `modelReasoningEffort`, so invalid values can reach Codex
unnoticed. Add upfront validation in `threadOptionsFor` (or a small helper it
calls) to only accept the allowed `ModelReasoningEffort` values: minimal, low,
medium, high, and xhigh. If `input.thinking` is anything else, reject it with a
clear DevSpace error before building the `ThreadOptions`, so bad inputs fail
immediately instead of later in the SDK.

---

Nitpick comments:
In `@skills/subagent-delegation/SKILL.md`:
- Around line 51-62: Clarify that the accepted values for the `--thinking` flag
are provider-specific and may differ between Codex, Claude, and ACP. Update the
guidance around `devspace agents run` in SKILL.md to mention that users must
choose a level supported by the selected provider, and reference the
`--thinking` option along with the relevant runtime/adapters behavior in
`src/local-agent-runtime.ts` and `src/local-agent-adapters.ts` so the
documentation makes this constraint explicit.

In `@src/local-agent-adapters.test.ts`:
- Line 11: Add missing negative-path tests for resolveAcpThinkingConfigUpdate in
local-agent-adapters.test.ts: the current coverage only verifies valid mappings
and one unsupported-value throw, but it should also assert the branches where
session metadata is absent, the session id is missing, and the ACP server does
not expose a thinking option. Reuse resolveAcpThinkingConfigUpdate directly in
the test cases and ensure the cursor and copilot adapter scenarios are
represented so these exported helper error paths stay covered.

In `@src/local-agent-store.test.ts`:
- Around line 19-24: The current test only covers `create()`/`get()` for
`thinking`, so it won’t catch regressions in `LocalAgentStore.update()`’s
separate SQL path. Extend `src/local-agent-store.test.ts` to update an existing
agent via `update()` and then assert the persisted `thinking` value is returned
by `get()`/readback, using the `LocalAgentStore` methods and `created.id` to
verify the update round-trips correctly.
🪄 Autofix (Beta)

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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f5b6fad4-666f-4391-88b9-9d5484f3c0e7

📥 Commits

Reviewing files that changed from the base of the PR and between 2da956f and 0ea953e.

📒 Files selected for processing (21)
  • docs/agent-profile-schema.md
  • docs/chatgpt-coding-workflow.md
  • docs/configuration.md
  • examples/agents/claude-implementer.md
  • examples/agents/pi-reviewer.md
  • skills/subagent-delegation/SKILL.md
  • src/cli.test.ts
  • src/cli.ts
  • src/db/migrations.ts
  • src/db/schema.ts
  • src/local-agent-adapters.test.ts
  • src/local-agent-adapters.ts
  • src/local-agent-profiles.test.ts
  • src/local-agent-profiles.ts
  • src/local-agent-runtime.test.ts
  • src/local-agent-runtime.ts
  • src/local-agent-store.test.ts
  • src/local-agent-store.ts
  • src/local-agent-targets.test.ts
  • src/local-agent-targets.ts
  • src/server.ts

Comment thread src/local-agent-adapters.ts

@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.

🧹 Nitpick comments (1)
src/local-agent-adapters.test.ts (1)

32-157: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Solid coverage for the ACP select-config resolvers.

Assertions for resolveAcpModelConfigUpdate and resolveAcpThinkingConfigUpdate correctly exercise flat-select, grouped-select, and invalid-value error paths, matching the shared resolver contract ({sessionId, configId, value} and the "Available values" error suffix).

One optional note: the two blocks (32-94 and 95-157) are structurally near-identical, differing only in category/fixture data. Consider extracting a small parameterized helper to reduce duplication, though this is purely a maintainability nit given the current size.

🤖 Prompt for 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.

In `@src/local-agent-adapters.test.ts` around lines 32 - 157, The test blocks for
resolveAcpModelConfigUpdate and resolveAcpThinkingConfigUpdate are duplicated
and only differ by category and fixture data. Extract a small parameterized
helper in local-agent-adapters.test.ts that can run the shared flat-select,
grouped-select, and invalid-value assertions for both resolvers, while keeping
the existing expected sessionId/configId/value and error-message checks intact.
🤖 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.

Nitpick comments:
In `@src/local-agent-adapters.test.ts`:
- Around line 32-157: The test blocks for resolveAcpModelConfigUpdate and
resolveAcpThinkingConfigUpdate are duplicated and only differ by category and
fixture data. Extract a small parameterized helper in
local-agent-adapters.test.ts that can run the shared flat-select,
grouped-select, and invalid-value assertions for both resolvers, while keeping
the existing expected sessionId/configId/value and error-message checks intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2068856b-6c1a-42b1-87d5-edbd0db3f6d7

📥 Commits

Reviewing files that changed from the base of the PR and between 0ea953e and 74b8c22.

📒 Files selected for processing (2)
  • src/local-agent-adapters.test.ts
  • src/local-agent-adapters.ts

@Waishnav

Waishnav commented Jul 5, 2026

Copy link
Copy Markdown
Owner Author

Addressed CodeRabbit review feedback in b34f540:

  • Added LocalAgentStore.update() coverage for persisted thinking values.
  • Added ACP negative-path coverage for missing session metadata, missing session id, and missing model/thinking config options.
  • Updated docs/skill guidance to state that thinking is provider-specific passthrough and DevSpace does not translate names between harnesses.

Intentionally skipped hardcoded Claude/Codex thinking enum validation. That would make DevSpace own provider naming and drift from the local harnesses. ACP remains dynamically validated because ACP advertises its available options at runtime.

@Waishnav Waishnav merged commit 11b1e8e into main Jul 5, 2026
4 checks passed
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