Repository navigation
[fix] Refuse an agent config the runtime cannot run, on every save - #7411
Conversation
Run the runtime's own AgentTemplate.from_params on every is_agent revision in _build_revision_commit and before the first write of simple create and edit, instead of only on agent-tool commits. The refusal is invalid_agent_configuration with the field paths in details.issues (parameters.agent.skills[0].body is required). A bad harness kind keeps its invalid_harness_kind envelope and now reaches every route as a 422. The SDK's skill, MCP and tool entry errors now carry their pydantic issues, so the location survives every re-raise and the API no longer walks __cause__.
📝 Summary
Merge Risk: 🟡 Moderate · up to A rejected edit can still change workflow or application metadata. Validate the effective revision before either edit writes metadata, and preserve server-error handling for unexpected parser failures before merging. Pre-merge checks |
|
Railway Preview Environment
PR closed or converted to draft. Environment absence verified; retained storage requires separate provider accounting. Post |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository YAML (base), Organization UI (inherited)
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a341238d-2c3c-44cd-95bb-27ee83991ff4
📒 Files selected for processing (24)
api/oss/src/apis/fastapi/workflows/exceptions.pyapi/oss/src/apis/fastapi/workflows/router.pyapi/oss/src/core/applications/service.pyapi/oss/src/core/tools/platform_handlers.pyapi/oss/src/core/workflows/service.pyapi/oss/src/core/workflows/types.pyapi/oss/tests/pytest/acceptance/tools/test_agent_config_tools.pyapi/oss/tests/pytest/unit/tools/test_agent_config_handlers.pyapi/oss/tests/pytest/unit/workflows/test_commit_agent_template_validation.pyapi/oss/tests/pytest/unit/workflows/test_commit_harness_validation.pyapi/oss/tests/pytest/unit/workflows/test_new_agent_template.pyopenspec/changes/cross-agent-config-editing/design.mdopenspec/changes/cross-agent-config-editing/specs/agent-config-management/spec.mdopenspec/changes/cross-agent-config-editing/tasks.mdsdks/python/agenta/sdk/agents/config_errors.pysdks/python/agenta/sdk/agents/dtos.pysdks/python/agenta/sdk/agents/mcp/errors.pysdks/python/agenta/sdk/agents/mcp/parsing.pysdks/python/agenta/sdk/agents/skills/errors.pysdks/python/agenta/sdk/agents/skills/parsing.pysdks/python/agenta/sdk/agents/tools/compat.pysdks/python/agenta/sdk/agents/tools/errors.pysdks/python/agenta/sdk/agents/tools/parsing.pysdks/python/oss/tests/pytest/unit/agents/test_config_entry_errors.py
💤 Files with no reviewable changes (1)
- api/oss/src/apis/fastapi/workflows/router.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review.
…y route
- Find the agent template the way the runtime does: parameters.agent when it
is an object, else the bare parameters or the prompt fallback.
- Name a single entry given as an object (skills: {...}) instead of a KeyError.
- Refuse a metadata-only simple edit of an unrunnable stored agent before the
artifact write.
- Check simple evaluator create and edit before their first write, and map the
refusal to 422 on the evaluator write routes and the template loader.
- Let only the parse's own refusals become invalid_agent_configuration; a parser
defect stays a 500.
- Skip embedded instructions in the instructions rule.
9c596d5
into
feat/cross-agent-config-editing
Stacked on #7409. It replaces a gate that exists only on that branch, so it targets
feat/cross-agent-config-editingand moves torelease/v0.122.3when #7409 merges.Context
An agent saved with a skill that has no
bodysaved fine. Every later run of that agent then failed with HTTP 500Invalid skill configuration ... 'body' Field required. #7409 added a check for this, but only for the agent tools (commit_revision,edit_agent_config,create_agent). A save from the playground, the SDK or the API still stored the broken config.Changes
The check now runs where every agent revision is built.
_reject_unrunnable_agentruns the runtime's ownAgentTemplate.from_paramson the result. Two places call it:_build_revision_commit, which builds every stored revision, and simple workflow and application create and edit, before their first write. The second call keeps a refused create from leaving an empty artifact behind. The check runs only when the uri key isagent, which is the same rule that sets theis_agentflag.The refusal is a 422 on every route, and the same envelope comes back in the agent tools' result:
{ "code": "invalid_agent_configuration", "message": "The agent configuration cannot run: parameters.agent.skills[0].body is required.", "retryable": false, "next_step": "Correct the fields listed in `details.issues` ...", "details": {"issues": ["parameters.agent.skills[0].body is required"]} }Before, the agent tools answered
final_validation_failedwithskills[0].body is required. Paths now start at the root, so they match the targets the operations use.What this replaces:
validatehook in_apply_delta(_agent_template_issues). The build covers it._reject_unreadable_harness_kind, which ran only on the checked commit. The runtime parse refuses the same values. The error still maps toinvalid_harness_kindwith the allowed list, andhandle_workflow_exceptionsnow maps it to 422 too, because simple create and edit can raise it now._reject_unreadable_agent_instructionsstays. The runtime reads a bare-stringinstructionsas "no prompt" and does not refuse it, so this rule is the API's own.An agent that is already broken. The check reads the result, not the change. A stored agent with a skill that has no
bodyrefuses every change until the same change fixes that skill. The issue names the field, andnext_stepsays to fix it in the same change. I chose this over letting unrelated edits through. Those edits would keep saving an agent that cannot run, and the field is easy to fix once it is named.Parts that hold an embed are skipped, as before, because embeds resolve before a run. A list entry that holds an embed keeps its index in the reported path.
SDK. The pydantic location now lives on the SDK errors.
SkillValidationError,MCPConfigurationErrorandToolConfigurationErrorshare a new base,ConfigEntryError, inagents/config_errors.py. It carriesissues(the location inside the entry, with a tool's union tag removed) anddescribe(field). The issues survive every re-raise, including the collected tool diagnostics. Before, the API walked__cause__, and the tools path lost the cause, so a bad tool was reported only by its message.Tests
api/.../test_commit_agent_template_validation.pycovers one test per writer: a full-data commit (playground and SDK), a delta commit, the plain commit, simple workflow create, idempotent create, simple workflow edit, simple application create and edit, and 422 on the routes. It also covers the broken-agent case in both directions: an unrelated change is refused and names the stored field, and a change that fixes the field is accepted.test_agent_config_handlers.pystill covers the three agent tools. It now expects the new code and path.test_config_entry_errors.py.unit/agents: 2005 passed.test_agent_config_tools.pyis updated, but I did not run it. I did not deploy this branch to a live stack.What to QA
parameters.agent.skills[0].body.POST /workflows/revisions/commit. You get a 422 withinvalid_agent_configuration.@ag.embed). The save succeeds.Review follow-up (Codex gpt-6-astra and CodeRabbit)
parameters.agentwhen it is an object, else the bare parameters or thepromptfallback. Before, an agent saved in the bare shape (parameters.skills[...]) skipped the check.skills: {...}, which the runtime reads as a list of one) is named, for exampleparameters.agent.skills.body is required. Before, it raised aKeyError.invalid_agent_configuration. A parser defect stays a 500.