Skip to content

fix(mcp): let create/update_agent_schedule write the validation config - #2761

Merged
vybe merged 2 commits into
Abilityai:devfrom
L4XB:fix/2759-mcp-schedule-validation-fields
Sep 15, 2026
Merged

vybe merged 2 commits into
Abilityai:devfrom
L4XB:fix/2759-mcp-schedule-validation-fields

Conversation

@L4XB

@L4XB L4XB commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2759.

The gap

list_agent_schedules and get_agent_schedule have returned validation_enabled, validation_prompt and validation_timeout_seconds since VALIDATE-001 landed. Neither create_agent_schedule nor update_agent_schedule accepted them, and both schemas are strict (additionalProperties: false), so they could not be smuggled through either — the post-execution validation hook could be observed over MCP but never configured over it.

The backend already takes all three on both write paths (ScheduleCreate in db_models.py:150-152, ScheduleUpdateRequest in models.py:3046-3048), so this is purely an MCP-layer parity gap. No backend change.

Same shape as #85, which added timeout_seconds / allowed_tools / model to these two tools; the validation_* trio was never added alongside them. I copied that pattern rather than inventing one.

Against the issue's acceptance list

  • Update semantics preserved — the three fields join the if (args.x !== undefined) block, so an omitted field is not sent and the stored value survives. Pinned by omits what was not passed, so a stored value survives.
  • Default unchanged — omitting all three on create sends nothing, so validation_enabled stays false. Pinned by leaves the safe default alone when they are omitted, which is the accept control: validation is not free, so a schedule created without asking for it must not get it.
  • Out-of-range timeout refused by name — validation_timeout_seconds is z.number().int().min(30).max(600).optional(), matching both the range documented on the column and the existing retry_delay_seconds bound. A bad value is a schema rejection naming the field, not a 500 from the backend.
  • The description states the consequence — enabling it buys one extra execution on the same agent after each technically-successful run, clean context, through the normal capacity path; on FAIL/PARTIAL the platform records business_status = failed_validation and raises one high-priority operator alert, and does not retry, because retries key on technical failure and validation only runs after technical success (Post-execution validation hook: run a validation playbook in clean context and record business-success status #1573). A cell asserts that text is actually in the schema, because it is the only place a caller will read it.

Two acceptance items I could not do here:

  • The round-trip test (create over MCP → list_agent_schedules reads it back → a fired run produces a linked validation execution and a business_status on the parent) needs a live backend and scheduler; these tests drive the tools against a fake TrinityClient, the same seam reports.test.ts and git.test.ts use.
  • "MCP server rebuilt so the shipped image exposes the new parameters" is your release step, not something in this diff.

The adjacent item the issue lists as out of scope — repo-declared schedules (template.yaml → schedules:) also not carrying these fields, related to #1198 — is untouched.

Tests

src/mcp-server/src/tools/schedules.validation.test.ts, 9 cells. Each was checked against a mutant that breaks the thing it names:

mutation killed by
create schema loses the three fields (the bug) 3 cells, incl. declares the fields in its parameter schema
create pass-through dropped sends all three fields to the backend
update sends every field, set or not omits what was not passed, so a stored value survives
timeout bound removed both rejects a timeout outside the documented 30-600 range cells
description drops the cost names the cost of enabling validation in the tool description
$ npm test          # src/mcp-server
280 passed, 0 failed

$ npx tsc --noEmit
(clean)

`list_agent_schedules` and `get_agent_schedule` have returned
`validation_enabled`, `validation_prompt` and `validation_timeout_seconds`
since VALIDATE-001 landed, and neither write tool accepted them. Both
schemas are strict, so the fields could not be smuggled through either --
the post-execution validation hook could be observed over MCP but never
configured over it. The backend takes all three on both write paths
(`ScheduleCreate`, `ScheduleUpdateRequest`), so this is an MCP-layer
parity gap and needs no backend change.

Same shape as Abilityai#85, which added `timeout_seconds` / `allowed_tools` /
`model` to these two tools; the `validation_*` trio was never added.

`validation_timeout_seconds` is bounded 30-600 in the Zod schema, so an
out-of-range value is refused by name rather than reaching the backend,
matching how `retry_delay_seconds` already handles the same range.

The `validation_enabled` description states what enabling it costs: one
extra execution on the same agent after each technically-successful run,
a `business_status = failed_validation` plus one operator alert on
FAIL/PARTIAL, and no retry -- retries key on technical failure, and
validation only runs after technical success (Abilityai#1573).

Refs Abilityai#2759
@vybe
vybe changed the base branch from main to dev September 14, 2026 15:14
Keep both the ent#498 deliver_to_workspace_email fields and the Abilityai#2759
validation_* fields in schedules.ts / types.ts. The description assertion
in schedules.validation.test.ts now reads the zod .description accessor,
because dev is on zod 4, which no longer serialises it into JSON.stringify.

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

merge-train: validated on #2820 (batch of 6, full suite green). Lane B — /validate-pr + /review; coverage mutation-proven (4 mutants, all caught; 375 tests pass). Consumer chain traced MCP schema → client → backend persist → scheduler runtime read.

@vybe
vybe merged commit e30564a into Abilityai:dev Sep 15, 2026
25 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.

2 participants