Skip to content

refactor(agent): collapse run-selection into AgentConfig, rename harness_kwargs#4840

Merged
mmabrouk merged 2 commits into
big-agentsfrom
feat/agent-config-structure-cleanup
Jun 25, 2026
Merged

refactor(agent): collapse run-selection into AgentConfig, rename harness_kwargs#4840
mmabrouk merged 2 commits into
big-agentsfrom
feat/agent-config-structure-cleanup

Conversation

@mmabrouk

Copy link
Copy Markdown
Member

What and why

PR #4821 review (comments 2 / 7 / 8) asked for one thing: there should be a single agent config, not an AgentConfig plus a separate sidecar RunSelection. The run-selection fields were split off into their own DTO and parsed separately, so "what the agent is" and "how it runs" lived in two places that both rode data.parameters.

This collapses them. harness, sandbox, and permission_policy are now plain fields on AgentConfig, parsed by the one AgentConfig.from_params(...). RunSelection is retired. The per-harness options bag harness_options is renamed to harness_kwargs (comment 8): a map keyed by harness name where the author sets per-harness knobs, e.g. Pi's system/append_system under pi_core, Claude's permissions under claude. permission_policy stays the sidecar action-permission, now inside AgentConfig.

POC: no back-compat, no deprecation shims. Shapes change cleanly.

Public-edge envelope change

The run-selection fields move from siblings of agent to inside it. They live under data.parameters.agent.{harness,sandbox,permission_policy}, not data.parameters.{harness,sandbox,permission_policy}.

Before:

"parameters": {
  "agent": { "agents_md": "...", "model": "..." },
  "harness": "pi_core",
  "sandbox": "local"
}

After:

"parameters": {
  "agent": { "agents_md": "...", "model": "...", "harness": "pi_core", "sandbox": "local", "permission_policy": "auto" }
}

The playground schema (AgentConfigSchema) and build_agent_v0_default already placed these inside agent, so the schema and default did not change. The FE request builders (agentRequest.ts, AgentChatSlice/transport.ts) stopped injecting top-level harness/sandbox and now default them inside the agent block.

The /run wire did NOT change

harness/sandbox ride the wire as explicit args to request_to_wire(harness=, sandbox=) (the harness adapter passes them from make_harness(agent_config.harness, ...) + select_backend(agent_config).sandbox); permissionPolicy rides wire_tools(). There are no new wire fields and the golden fixtures are untouched. This is an envelope/config-placement + parsing change, not a contract change. sandbox stays a backend/environment concern read before the session is built; no adapter consumes it.

Decisions

  • Retire RunSelection. Nothing else needed it; one agent definition is the whole point of the comment. Removed its export from agenta.sdk.agents and the top-level agenta package.
  • harness_options -> harness_kwargs. Today's bag already was the general per-harness map the comment described, so this is a reconcile-rename, not a new field.
  • sandbox left in place (not removed). The sibling sidecar-uri-config work will replace sandbox with an optional uri next; this PR moves sandbox cleanly into AgentConfig so that follow-up is a small field swap.

Tests

  • SDK agents: 342 passed. service-agent: 38 passed.
  • FE playground: 121 (agentRequest 19, incl. a new test asserting the defaults land inside agent). entity-ui: 126.
  • entity-ui + playground typecheck green; ruff + prettier + eslint clean.
  • Codex (xhigh) reviewed: runtime sound, wire unchanged.

Docs

Updated the interface inventory pages (agent-config-schema, agent-messages, workflow-invoke, agent-service-handler, neutral-runtime-dtos) and the affected documentation pages (agent-configuration, ground-truth, ports-and-adapters, architecture, harness-adapters, adapters/pi, adapters/agenta, agent-template) to the "everything under AgentConfig" shape and the harness_kwargs name.

Deferred

  • services/agent/src/protocol.ts:354 has a harness_options doc comment (describes the Python-side bag). It is in the runner dir (sibling HTTP-MCP impl active there), so untouched; rename in a runner-owned change.

https://claude.ai/code/session_01GYo3UEfvsZpncagqb28Mbc

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 24, 2026
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jun 25, 2026 11:37am

Request Review

@dosubot dosubot Bot added the refactoring A code change that neither fixes a bug nor adds a feature label Jun 24, 2026
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 297f3d17-222a-4211-acd0-5e21cc5b03ee

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR updates agent-workflow docs, SDK models, service wiring, and web request builders so run-selection fields live on AgentConfig, harness_options becomes harness_kwargs, and RunSelection is removed from parsing and exports.

Changes

Agent Config Structure Cleanup

Layer / File(s) Summary
High-level docs
docs/design/agent-workflows/documentation/*, docs/design/agent-workflows/projects/agent-config-structure-cleanup/status.md
Docs and the status note now describe run-selection fields on AgentConfig and replace harness_options wording with harness_kwargs.
Interface docs
docs/design/agent-workflows/interfaces/*, docs/design/agent-workflows/documentation/adapters/*
Interface docs now place run-selection fields under parameters.agent and update adapter examples to use harness_kwargs.
SDK model and exports
sdks/python/agenta/__init__.py, sdks/python/agenta/sdk/agents/__init__.py, sdks/python/agenta/sdk/agents/dtos.py, sdks/python/agenta/sdk/agents/utils/wire.py, sdks/python/agenta/sdk/utils/types.py, sdks/python/oss/tests/pytest/unit/agents/test_dtos_agent_config.py
AgentConfig now carries run-selection fields directly, parsing helpers populate harness_kwargs, and the public re-export surface no longer exposes RunSelection.
Harness adapters
sdks/python/agenta/sdk/agents/adapters/*, sdks/python/oss/tests/pytest/unit/agents/adapters/*, sdks/python/oss/tests/pytest/unit/agents/test_harness_adapters.py, sdks/python/oss/tests/pytest/unit/agents/test_wire_contract.py
Claude and harness adapters now consume harness_kwargs, and unit tests cover the updated Pi, Claude, Agenta, and wire-contract behavior.
Service runtime
services/oss/src/agent/app.py, services/oss/tests/pytest/unit/agent/*
_agent and select_backend now derive backend, auth, and permission policy from AgentConfig, and the service tests use AgentConfig inputs.
Web request flow
web/oss/src/components/AgentChatSlice/assets/transport.ts, web/packages/agenta-playground/src/state/execution/agentRequest.ts, web/packages/agenta-playground/tests/unit/agentRequest.test.ts, web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/*
The playground request builder, chat transport, and schema editor now nest run-selection defaults under parameters.agent and read Claude permissions from harness_kwargs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Agenta-AI/agenta#4771: Updates the same SDK DTO/export surface around RunSelection removal and harness_options to harness_kwargs.
  • Agenta-AI/agenta#4772: Touches the same /invoke service path and backend-selection wiring in services/oss/src/agent/app.py.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.00% which is insufficient. The required threshold is 60.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 clearly names the two main changes: collapsing run-selection into AgentConfig and renaming harness_kwargs.
Description check ✅ Passed The description matches the refactor and its related envelope, wire, and docs 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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agent-config-structure-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@mmabrouk

Copy link
Copy Markdown
Member Author

Changes made — maps the approved #4821 review comments to the diff.

#4821 c3470018175 + c3470081368 ("harness and sandbox are part of AgentConfig — don't have anything outside agent; define it once")

  • AgentConfig (sdks/python/agenta/sdk/agents/dtos.py) now owns harness / sandbox / permission_policy. AgentConfig.from_params parses them via a new _parse_run_selection (reads the agent sub-dict, lowercases, falls back to defaults).
  • RunSelection is retired: class deleted, export removed from agenta.sdk.agents.__init__ and the top-level agenta package.
  • services/oss/src/agent/app.py: _agent no longer calls RunSelection.from_params; select_backend(agent_config) reads agent_config.sandbox; harness from agent_config.harness; permission_policy from agent_config.permission_policy.
  • FE request builders (agentRequest.ts, AgentChatSlice/transport.ts) default harness/sandbox INSIDE parameters.agent, not as top-level params siblings.

#4821 c3469634113 (general harness_kwargs map; permission_policy stays the sidecar action-permission)

  • Renamed the per-harness bag harness_options -> harness_kwargs across dtos.py, adapters/harnesses.py, adapters/claude_settings.py, utils/wire.py, the FE AgentConfigControl.tsx / ClaudePermissionsControl.tsx, and all tests. It is the map keyed by harness name (Pi system/append_system under pi_core, Claude permissions under claude). permission_policy stays the action-permission, now a field on AgentConfig.

Wire impact: none. The /run payload still carries top-level harness/sandbox/permissionPolicy via request_to_wire args + wire_tools(). Golden fixtures untouched.

Tests: SDK agents 342, service-agent 38, FE playground 121 (agentRequest 19, +1 new nested-under-agent test), entity-ui 126. ruff + prettier + eslint clean. Codex (xhigh) reviewed (runtime sound, wire unchanged; reworded a now-inaccurate SessionConfig "sandbox absent" docstring per its flag).

Docs: synced the inventory pages (agent-config-schema, agent-messages, workflow-invoke, agent-service-handler, neutral-runtime-dtos) + documentation pages (agent-configuration, ground-truth, ports-and-adapters, architecture, harness-adapters, adapters/pi, adapters/agenta, agent-template) to the new shape.

Deferred: services/agent/src/protocol.ts:354 still has a harness_options doc comment (runner dir, sibling HTTP-MCP impl active there) — rename in a runner-owned change.

GitButler note: hit the documented stale-but mark hijack (every stage/rub routed to a sibling lane). Recovered via commit-to-that-lane + but rub <commit> <my-lane> (move); the commit is exactly the 33 files of this PR, the sibling lane is untouched.

@mmabrouk

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 24, 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.

@mmabrouk

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 24, 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.

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-06-25T12:05:32.499Z

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 615bf410-9144-4148-9e01-f5971b298a17

📥 Commits

Reviewing files that changed from the base of the PR and between 0e7f4f7 and 41e2811.

📒 Files selected for processing (33)
  • docs/design/agent-workflows/documentation/adapters/agenta.md
  • docs/design/agent-workflows/documentation/adapters/pi.md
  • docs/design/agent-workflows/documentation/agent-configuration.md
  • docs/design/agent-workflows/documentation/agent-template.md
  • docs/design/agent-workflows/documentation/architecture.md
  • docs/design/agent-workflows/documentation/ground-truth.md
  • docs/design/agent-workflows/documentation/ports-and-adapters.md
  • docs/design/agent-workflows/interfaces/in-service/agent-service-handler.md
  • docs/design/agent-workflows/interfaces/in-service/harness-adapters.md
  • docs/design/agent-workflows/interfaces/in-service/neutral-runtime-dtos.md
  • docs/design/agent-workflows/interfaces/public-edge/agent-config-schema.md
  • docs/design/agent-workflows/interfaces/public-edge/agent-messages.md
  • docs/design/agent-workflows/interfaces/public-edge/workflow-invoke.md
  • docs/design/agent-workflows/projects/agent-config-structure-cleanup/status.md
  • sdks/python/agenta/__init__.py
  • sdks/python/agenta/sdk/agents/__init__.py
  • sdks/python/agenta/sdk/agents/adapters/claude_settings.py
  • sdks/python/agenta/sdk/agents/adapters/harnesses.py
  • sdks/python/agenta/sdk/agents/dtos.py
  • sdks/python/agenta/sdk/agents/utils/wire.py
  • sdks/python/agenta/sdk/utils/types.py
  • sdks/python/oss/tests/pytest/unit/agents/adapters/test_claude_settings.py
  • sdks/python/oss/tests/pytest/unit/agents/test_dtos_agent_config.py
  • sdks/python/oss/tests/pytest/unit/agents/test_harness_adapters.py
  • sdks/python/oss/tests/pytest/unit/agents/test_wire_contract.py
  • services/oss/src/agent/app.py
  • services/oss/tests/pytest/unit/agent/test_default_agent_config.py
  • services/oss/tests/pytest/unit/agent/test_select_backend.py
  • web/oss/src/components/AgentChatSlice/assets/transport.ts
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/AgentConfigControl.tsx
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/ClaudePermissionsControl.tsx
  • web/packages/agenta-playground/src/state/execution/agentRequest.ts
  • web/packages/agenta-playground/tests/unit/agentRequest.test.ts
💤 Files with no reviewable changes (2)
  • sdks/python/agenta/init.py
  • sdks/python/agenta/sdk/agents/init.py

Comment on lines +210 to +212
| harness | yes, enum | yes, on `AgentConfig` | wired, picks the harness class | Enum-enforced. The runtime validates via `make_harness`. |
| sandbox | yes, enum | yes, on `AgentConfig` | wired to the backend, absent from `SessionConfig` | Backend concern, not agent identity. |
| permission_policy | yes, enum | yes, on `AgentConfig` | wired to `SessionConfig` | Only the Claude harness reads it. Pi ignores it, so it is decorative for `pi_core` and `pi_agenta`. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Reword the permission_policy row to match the new ownership.

This still says the policy is wired to SessionConfig, but the flattened contract keeps it on AgentConfig and the runtime consumes it through harness wiring. Please update the wording so ownership stays on the agent config. Per the PR objective, permissionPolicy still rides through wire_tools().

Comment thread sdks/python/agenta/sdk/agents/dtos.py Outdated
Comment thread web/oss/src/components/AgentChatSlice/assets/transport.ts
Comment thread web/packages/agenta-playground/src/state/execution/agentRequest.ts
@mmabrouk

Copy link
Copy Markdown
Member Author

Addressed CodeRabbit's two substantive findings (commit 8aa3c9005d):

  • dtos.py _parse_harness_kwargs: now distinguishes an absent harness_kwargs (falls back to defaults) from an explicit empty {} (clears inherited per-harness settings). Was options or defaults, which silently restored defaults on an empty map. +1 regression test.
  • FE double-shape emit (transport.ts configFor + agentRequest.ts withAgentRunDefaults): when a nested agent is present, the legacy top-level run-selection keys (harness/sandbox/permission_policy) are now stripped before spreading, so a partially-migrated config emits only the nested agent shape, never both. +1 regression test.

Skipped the agent-configuration.md:212 permission_policy ownership wording nitpick (doc polish, POC).

Tests green: SDK dtos 21, playground agentRequest 20; ruff/prettier clean; typecheck clean.

@mmabrouk mmabrouk left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks good to me. Please merge

@mmabrouk mmabrouk added lgtm This PR has been approved by a maintainer needs-review Agent updated; awaiting Mahmoud's review labels Jun 25, 2026
@mmabrouk mmabrouk force-pushed the feat/agent-config-structure-cleanup branch from 2610078 to cec8c43 Compare June 25, 2026 10:42
mmabrouk added 2 commits June 25, 2026 12:56
…ess_kwargs

Move harness/sandbox/permission_policy from the separate RunSelection DTO into
AgentConfig (one agent definition, under data.parameters.agent). Retire RunSelection.
Rename the per-harness options bag harness_options -> harness_kwargs. The /run wire is
unchanged (golden fixtures untouched). PR #4821 review comments 2/7/8.

Claude-Session: https://claude.ai/code/session_01GYo3UEfvsZpncagqb28Mbc
@mmabrouk mmabrouk removed the needs-review Agent updated; awaiting Mahmoud's review label Jun 25, 2026
@mmabrouk

Copy link
Copy Markdown
Member Author

You already lgtm'd this; the only change since is a small CodeRabbit fix (an explicit empty harness_kwargs: {} now clears inherited settings; the FE request builder no longer emits both wire shapes). Please just re-glance that small diff — no full re-review needed. It merges after #4830 and #4839 land (it stacks on them).

@mmabrouk

Copy link
Copy Markdown
Member Author

FYI — a small CodeRabbit fix was applied since your lgtm (explicit empty harness_kwargs: {} now clears inherited settings; the FE request builder no longer emits both wire shapes). No action needed; it merges after #4830 and #4839.

@mmabrouk mmabrouk force-pushed the feat/agent-model-picker branch from 673b178 to c406a5d Compare June 25, 2026 11:36
@mmabrouk mmabrouk force-pushed the feat/agent-config-structure-cleanup branch from cec8c43 to 3f051c8 Compare June 25, 2026 11:36
@mmabrouk mmabrouk changed the base branch from feat/agent-model-picker to big-agents June 25, 2026 12:05
@mmabrouk mmabrouk merged commit ce81b73 into big-agents Jun 25, 2026
35 of 36 checks passed
ardaerzin added a commit that referenced this pull request Jun 25, 2026
The inspect-picker port pulled two names from the stacked feat/agent-config-structure-cleanup
(#4840), whose backend is not in big-agents yet: the harness_options -> harness_kwargs rename and a
pi_core default harness. big-agents' backend still reads the harness_options key and only knows
pi/agenta/claude, so on big-agents the renamed bag would be dropped and a harness-less config would
send an unknown harness.

Revert both to match the big-agents contract: write the Claude permission bag under harness_options,
and default an unset harness to "pi". The nested parameters.agent shape is kept (big-agents'
RunSelection.from_params already reads it), and the inspect-driven picker is kept (it falls back to
the schema catalog when /inspect publishes no models). Flipping these back is a one-line follow-up
once #4840 lands on big-agents.

tsc 0, eslint clean, playground unit tests pass (28).
ardaerzin added a commit that referenced this pull request Jun 25, 2026
…ents

Rebuilds the contained agent config-panel branch on top of big-agents after the agent stack landed
(#4830 canonical /inspect + models, #4839 model picker, #4840 collapse run-selection into AgentConfig
+ harness_kwargs). The inspect-driven picker, connectionUtils, inspectMeta and EnumSelectControl we
had ported now live in big-agents verbatim, so they collapse out — this branch is only our genuine UX
delta on top:

- AgentConfigControl as schema-driven accordion sections (ConfigAccordionSection primitive)
- per-item drawers on the shared EnhancedDrawer (ConfigItemDrawer) with lazy content
- two-pane skill editor, MCP server form, tool form, harness select, markdown/code/JSON editors
- Authentication as radio cards with explainers; live JSON-edit sync
- chat panel: inline per-turn run errors + truncation, empty-turn collapse
- playground wiring (header menu view modes, height calc, router)

Coherent with the merged backend: harness/sandbox/permission_policy ride parameters.agent,
harness_kwargs bag, pi_core default — taken from big-agents (the earlier Option-A reverts are undone).

tsc 0 (entity-ui/agenta-ui/entities/playground; oss 593 baseline, 0 new), eslint clean,
unit tests pass (entity-ui 126, playground 122, entities 683).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactoring A code change that neither fixes a bug nor adds a feature size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant