Repository navigation
Description
Problem
On 2026-11-09 the log lines of the stage job of the roadmap Service show StructuredOutputValidationError: N schema violation(s), with N from 0 to 9. They give no text of the violations: no loc, no type, no message. The cause stays hidden.
This hid two real faults for one day. The null reference reason (#4214) and the cut at 4096 output tokens (#4220) both showed as 0 schema violation(s). The same line hid the joined tool call arguments of #4228.
Where the text is lost:
RunTrace._add_violationsinsrc/devops_cli/roadmap/agent_run.py(about line 292) keeps only the count of the retry prompt. It counts only a retry prompt whose content is a list, and it drops the list._stoppedinsrc/devops_cli/roadmap/stage/stage_toolbox.pyraisesStructuredOutputValidationError(message, violations=trace.violations). The error holds a number and no text._failure_ofinsrc/devops_cli/roadmap/stage/stage.py(about line 1597) writes onlyMESSAGES.roadmap.stage_violations.format(count=...)into theStageFailure.
#4260 (merged) keeps a refused reply that failed the gates (<n>.refused.json). A reply that fails the schema never reaches the gates, so nothing is kept for it. #4204 names this in its scope: a schema violation is out of that delivery.
Expected
- The failure line and the log name, for a run that ended on a schema failure:
- the first violations: at most 3, each with
loc,typeand a message cut at 200 characters; - the stop reason: length, no tool call, invalid arguments or validation;
- the count.
- the first violations: at most 3, each with
- The text holds no reply text that could hold a secret. Each message passes through the masking helper of the project (
mask_secretsinsrc/devops_cli/security/sanitizer.py). - The file
<n>.refused.jsonof fix(roadmap): keep refused stage replies, stop placeholder replies #4260 also records a schema failure, with the same fields.
Acceptance criteria
- A unit test runs a stage plan that fails validation with two violations, one with
locreferences.0.reason. It asserts that the text of theStageFailurecontainsreferences.0.reasonand the error type. Today the text holds only the count, so the test fails. - A unit test runs a plan that the provider stops by length. It asserts that the failure text names the length reason. (Run:
uv run pytest tests/<stage test file> -k violation.) - A unit test gives 5 violations and asserts that the text names 3 of them and the count 5, and that a message of 300 characters is cut at 200.
- A unit test gives a violation message that holds a token-shaped secret and asserts that the failure text and the kept file hold the masked value.
- A unit test asserts that a schema failure writes
<n>.refused.jsonwith the same fields, and that the staging of the item deletes the file as for a gate refusal.
Existing tool considered
The pydantic ValidationError.errors() and the retry prompt of pydantic-ai already carry loc, type and msg for each violation. The change only keeps these fields instead of their count, and it uses the existing masking helper. No new library and no hand-made parser are needed.
Cost
- Build: small. About 3 files change (
agent_run.py,stage_toolbox.py,stage.py) plus message text and tests. About 30,000 tokens and 1 to 2 hours. - Keep: low. The fields come from the library types, so a library change shows in the tests.
- Fix: the cost of not building it is higher. Each hidden fault cost a day of failed stage rounds, and found only by reading gateway logs by hand.
Related
#4204, #4214, #4220, #4228, #4260.
Proposed design
Problem statement
A stage run that ends on a schema failure logs only StructuredOutputValidationError: N schema violation(s). The log has no loc, no type, no message and no stop reason. This hid the faults of #4214, #4220 and #4228 for one day. The run trace keeps only the count, the error carries only the count, and the failure text holds only the count. A reply that fails the schema leaves no kept file.
Acceptance criteria
Requirement: Failure text names the violations
The text of a StageFailure for a run that ends on a schema failure SHALL name the loc, the type and the message of each kept violation, and the error class.
Scenario: Plan fails validation with two violations
- WHEN A stage plan run fails validation with two violations, and one has
locreferences.0.reason - THEN The
reasonof theStageFailurecontainsreferences.0.reason, the violation type andStructuredOutputValidationError
Requirement: Failure text names the stop reason
The failure text of a stage run that ends with no reply SHALL name the stop reason: length, no tool call, invalid arguments or validation.
Scenario: Provider stops the plan by length
- WHEN The provider stops a plan run by length (
uv run pytest tests/roadmap/stage -k violation) - THEN The failure text names the length reason
Requirement: Violations are bounded
The failure text SHALL name at most 3 violations, SHALL give the full count, and SHALL cut each message at 200 characters.
Scenario: Five violations and a long message
- WHEN A run gives 5 violations, and one message has 300 characters
- THEN The text names 3 violations and the count 5, and the long message ends at 200 characters
Requirement: Violation text is masked
Each loc and each message in the failure text and in the kept file MUST pass through mask_secrets before the job keeps or logs it.
Scenario: Message holds a token-shaped secret
- WHEN A violation message holds a token-shaped secret
- THEN The failure text and the kept file hold the masked value and not the secret
Requirement: The input of a violation is never kept
The job MUST NOT keep the input or the ctx of a violation in the trace, the error, the failure text or the file.
Scenario: Violation carries the reply value as input
- WHEN A violation has an
inputvalue that holds the text of the reply - THEN No kept field and no failure text holds that value
Requirement: Schema failure writes the refused file
A schema failure of a stage plan SHALL write <n>.refused.json with the same fields as the failure text, and the staging of the item SHALL delete the file as it does for a gate refusal.
Scenario: Schema failure then staging
- WHEN A plan run fails the schema, and later a rerun stages the item
- THEN The failed run leaves
<n>.refused.jsonwith the stop reason, up to 3 violations and the count, and the staging deletes it
Existing Tool Considered
Pydantic ValidationError.errors() and the retry prompt of pydantic-ai (RetryPromptPart.content) already carry loc, type and msg for each violation. The project helper mask_secrets in src/devops_cli/security/sanitizer.py already masks text. No new library is needed. The change keeps these fields in place of their count and builds no parser. Cost to build: about 30,000 tokens and 1 to 2 hours. Cost to keep: low, as the fields come from library types. No alternatives check has run for this item.
Key questions
- Where does the text of the violations exist today, and where is it lost?: The retry prompt of the output tool holds the violations in a list in
RetryPromptPart.content.RunTrace._add_violationsinsrc/devops_cli/roadmap/agent_run.pystores only the length of that list._stoppedinstage_toolbox.pypasses only the count to the error, and_failure_ofinstage.pyformats only the count. [sources: src/devops_cli/roadmap/agent_run.py, src/devops_cli/roadmap/stage/stage_toolbox.py, src/devops_cli/roadmap/stage/stage.py] - An earlier change kept the field path out of the error, because a path can be a key that the model invented. Does the new text break that rule?: Keep
loc, as the issue asks, but treat it as model text. Pass eachlocand message throughmask_secretsand cut each at 200 characters. Never keep theinputor thectxof a violation. The issue outranks the earlier rule because the hidden cause cost a day of failed rounds. (best practice) [sources: openspec/changes/archive/2026-10-30-2772-stage-group-files/proposal.md, src/devops_cli/security/sanitizer.py]- Rejected: Keep the count only. This hid three faults for one day.
- Chosen: Keep loc, type and message, masked and cut. It gives the cause, and the masking helper covers the secret risk.
- Rejected: Keep type and message, drop loc. The path is the most useful field to find a schema fault such as references.0.reason.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 9, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(roadmap)scope of the title gives the scope.It hid real faults for a full day but does not block delivery or expose a security risk.It cuts debug time from reading gateway logs by hand to reading one log line, but does not change user-facing behaviour.Three files change, the fields come from existing library types, and the candidate estimates 1 to 2 hours.Both preserve schema violation details, but #437 targets the model retry prompt while the candidate targets the human-facing log line and StageFailure text.devops-cli-service commentedon Nov 9, 2026
Status set to Ready at cefc184 (see proposed design in issue body).
devops-cli-service commentedon Nov 9, 2026
Released in v0.103.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.103.0
devops-cli-service commentedon Nov 9, 2026
Live since 2026-11-09 21:51 UTC