Skip to content

Commit c1ac813

Browse files
fix(#22): add structured output instructions to code agent
The code agent was missing structured output guidance that the fix and review agents already have. Every code agent run failed harness validation with "output/code-result.json not found" because the agent never knew it needed to produce the file. Changes: - agents/code.md: Add "Structured output" section (modeled on agents/fix.md) between "Constraints" and "Failure handling", documenting the MUST requirement to write the output JSON and validate it with fullsend-check-output. - skills/code-implementation/SKILL.md: Add MANDATORY language and fullsend-check-output validation to the existing output-writing block in step 3. Add new step 11 ("Verify structured output") as a final check before exit with a recovery path if the file is missing. Note: No test suite or lint command exists in this markdown-only repo. Changes were verified by manual review of the diff. Closes #22
1 parent aa64fc8 commit c1ac813

2 files changed

Lines changed: 81 additions & 2 deletions

File tree

agents/code.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,36 @@ the review agent — if the triage was wrong, your code will fail review.
9292
- If the retry limit is exceeded and tests still fail, do not commit broken
9393
code. Stop. The post-script reports the failure.
9494

95+
## Structured output
96+
97+
You MUST produce a JSON file at `$FULLSEND_OUTPUT_DIR/$FULLSEND_OUTPUT_FILE`
98+
(typically `code-result.json`) that documents the target branch for PR
99+
creation. The post-script reads this file to create the PR against the
100+
correct branch. Without this file, the harness validation loop will reject
101+
the run.
102+
103+
Write this file early — during step 3 of the skill, after determining
104+
the target branch — so it is available even if the agent hits a timeout
105+
or error later.
106+
107+
The file must contain at minimum:
108+
109+
```json
110+
{
111+
"target_branch": "<branch-name>"
112+
}
113+
```
114+
115+
After writing the file, validate it:
116+
117+
```bash
118+
fullsend-check-output "${FULLSEND_OUTPUT_DIR}/${FULLSEND_OUTPUT_FILE}"
119+
```
120+
121+
If validation fails, read the error output, fix the JSON file, and
122+
re-run the check. If it still fails after 3 attempts, write the best
123+
JSON you have and exit.
124+
95125
## Failure handling
96126

97127
Secret scanning is **non-negotiable**. The `scan-secrets` helper runs before

skills/code-implementation/SKILL.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ use that branch. Otherwise, determine the repo's default branch:
186186
git rev-parse --abbrev-ref origin/HEAD | cut -d/ -f2
187187
```
188188

189-
Write your chosen branch to the structured output file so the post-script
190-
knows which branch to target the PR against:
189+
**MANDATORY: Write the structured output file.** You MUST write this file
190+
so the post-script knows which branch to target the PR against. Without
191+
this file, the harness validation loop will reject the run.
191192

192193
```bash
193194
mkdir -p "${FULLSEND_OUTPUT_DIR}"
@@ -198,6 +199,14 @@ cat > "${FULLSEND_OUTPUT_DIR}/${FULLSEND_OUTPUT_FILE}" <<RESULT
198199
RESULT
199200
```
200201

202+
Validate the output immediately after writing:
203+
204+
```bash
205+
fullsend-check-output "${FULLSEND_OUTPUT_DIR}/${FULLSEND_OUTPUT_FILE}"
206+
```
207+
208+
If validation fails, fix the JSON and re-run the check.
209+
201210
Write this output early (during planning, after determining the target
202211
branch) so it is available even if the agent hits a timeout or error later.
203212
The post-script validates this against the repo's allowed branches.
@@ -739,6 +748,46 @@ message. The post-script runs an authoritative pre-commit on the runner.
739748
**Do not push the branch.** The post-script handles pushing, PR creation,
740749
and failure reporting.
741750

751+
### 11. Verify structured output
752+
753+
Before exiting, verify the structured output file exists and is valid.
754+
This is a **MANDATORY** final check — even if the commit succeeded, the
755+
harness validation loop will reject the run without this file.
756+
757+
```bash
758+
echo "::notice::STEP 11: Verify structured output"
759+
```
760+
761+
Check that the file exists:
762+
763+
```bash
764+
test -f "${FULLSEND_OUTPUT_DIR}/${FULLSEND_OUTPUT_FILE}" \
765+
&& echo "Output file exists" \
766+
|| echo "ERROR: Output file missing"
767+
```
768+
769+
If the file is missing (e.g., step 3 was interrupted before writing it),
770+
write it now:
771+
772+
```bash
773+
mkdir -p "${FULLSEND_OUTPUT_DIR}"
774+
cat > "${FULLSEND_OUTPUT_DIR}/${FULLSEND_OUTPUT_FILE}" <<RESULT
775+
{
776+
"target_branch": "<branch-name>"
777+
}
778+
RESULT
779+
```
780+
781+
Validate the output:
782+
783+
```bash
784+
fullsend-check-output "${FULLSEND_OUTPUT_DIR}/${FULLSEND_OUTPUT_FILE}"
785+
```
786+
787+
If validation fails, read the error output, fix the JSON file, and
788+
re-run the check. If it still fails after 3 attempts, write the best
789+
JSON you have and exit.
790+
742791
## Partial work
743792

744793
If you hit a token limit or context window boundary before completing the

0 commit comments

Comments
 (0)