[PR #1416] [MERGED] [codex] Fail malformed structured agent outputs #5081

Closed
opened 2026-10-22 04:13:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1416
Author: @Xelvanis
Created: 5/27/2026
Status: ✅ Merged
Merged: 5/27/2026
Merged by: @Xelvanis

Base: refactor ← Head: chore/generation-agent-focused-tests


📝 Commits (1)

  • 115786d test: cover agent executor failure paths

📊 Changes

2 files changed (+296 additions, -4 deletions)

View changed files

➕ src/engine/agents-runtime/executor/agent-executor.test.ts (+274 -0)
📝 src/engine/agents-runtime/executor/agent-executor.ts (+22 -4)

📄 Description

Linked issue

No linked GitHub issue.

Why this change

  • Structured agents could return malformed JSON and still be recorded as successful results with { parseError: true } data.
  • Downstream generation and UI code treat successful agent results as usable, so malformed structured output could bypass the visible failed-agent path instead of surfacing a retryable failure.
  • The executor had no focused regression coverage for this failure path, text-result sanitization, empty provider responses, or batch fallback behavior.

What changed

  • Structured agent response parsing now returns a failed AgentResult when JSON parsing fails.
  • Batched agent parsing now treats malformed structured result blocks as failed blocks and retries those agents individually.
  • Added focused executor tests for fenced/repaired JSON, custom JSON result types, malformed structured output, text-agent sanitization, empty responses, missing batch blocks, and malformed batch-block retry.

Refactor impact

Primary owner:

Engine generation / agents runtime executor.

Impact areas reviewed:

  • Agent executor direct response parsing.
  • Agent executor tool-loop final response parsing.
  • Batched agent response parsing and individual retry fallback.
  • Pre-generation injection filtering for failed results.
  • Runtime generation failed-agent UI result handling.
  • Agent-run persistence of success/error state.
  • Legacy Spotify parseError recovery parity. That gap is tracked separately instead of restoring generic fake success for every structured agent.

Boundary notes:

  • Engine-only change under src/engine/agents-runtime/executor.
  • No React, Zustand, Tauri, shared API, Rust, or remote-runtime boundary changes.
  • No raw runtime adapter or host-capability path touched.

Pressure points touched:

  • None of the listed pressure points were touched.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

Local validation run before opening the PR:

  • pnpm vitest run src/engine/agents-runtime/executor/agent-executor.test.ts
  • pnpm vitest run src/engine/agents-runtime/executor/agent-executor.test.ts src/engine/generation/agent-runner.test.ts src/engine/agents-runtime/debug.test.ts
  • pnpm typecheck
  • pnpm check:architecture
  • pnpm test - 39 files, 243 tests passed
  • git diff --check origin/refactor...HEAD
  • git merge-tree $(git merge-base HEAD origin/refactor) HEAD origin/refactor after fetching origin/refactor; no merge conflict markers reported.

PR checks observed after opening the draft:

  • Frontend, Architecture, and Organization passed.
  • Rust Capability Layer passed.
  • Browser Smoke and Performance passed.
  • Auto-label passed.
  • CodeRabbit reported success with review skipped.

No browser or native Tauri manual verification was run because this change is isolated to React-free engine executor behavior and covered by focused unit tests.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

No docs or release-note updates were made. This changes internal agent failure semantics and adds focused executor coverage; no public command, UI workflow, architecture guidance, or release claim changed.

UI evidence

N/A - no visible UI changes.

Summary by CodeRabbit

  • Tests

    • Added comprehensive test coverage for agent execution and batch operations, including error handling and retry scenarios.
  • Bug Fixes

    • Improved error detection for malformed agent responses with clearer error reporting.
    • Enhanced batch execution reliability with targeted retry logic for individual agent failures.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/1416 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/27/2026 **Status:** ✅ Merged **Merged:** 5/27/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `chore/generation-agent-focused-tests` --- ### 📝 Commits (1) - [`115786d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/115786d7e2f4353fcb8e56fbdd044fe978f7cb07) test: cover agent executor failure paths ### 📊 Changes **2 files changed** (+296 additions, -4 deletions) <details> <summary>View changed files</summary> ➕ `src/engine/agents-runtime/executor/agent-executor.test.ts` (+274 -0) 📝 `src/engine/agents-runtime/executor/agent-executor.ts` (+22 -4) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue <!-- Every user-facing PR should reference a feature request or issue report when practical. --> No linked GitHub issue. ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - Structured agents could return malformed JSON and still be recorded as successful results with `{ parseError: true }` data. - Downstream generation and UI code treat successful agent results as usable, so malformed structured output could bypass the visible failed-agent path instead of surfacing a retryable failure. - The executor had no focused regression coverage for this failure path, text-result sanitization, empty provider responses, or batch fallback behavior. ## What changed <!-- List the key changes in this PR. --> - Structured agent response parsing now returns a failed `AgentResult` when JSON parsing fails. - Batched agent parsing now treats malformed structured result blocks as failed blocks and retries those agents individually. - Added focused executor tests for fenced/repaired JSON, custom JSON result types, malformed structured output, text-agent sanitization, empty responses, missing batch blocks, and malformed batch-block retry. ## Refactor impact Primary owner: <!-- Examples: app shell, catalog, chat mode, roleplay mode, game mode, runtime generation, world-state, shared API, engine generation, Rust storage, imports, remote runtime. --> Engine generation / agents runtime executor. Impact areas reviewed: - Agent executor direct response parsing. - Agent executor tool-loop final response parsing. - Batched agent response parsing and individual retry fallback. - Pre-generation injection filtering for failed results. - Runtime generation failed-agent UI result handling. - Agent-run persistence of success/error state. - Legacy Spotify parseError recovery parity. That gap is tracked separately instead of restoring generic fake success for every structured agent. Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - Engine-only change under `src/engine/agents-runtime/executor`. - No React, Zustand, Tauri, shared API, Rust, or remote-runtime boundary changes. - No raw runtime adapter or host-capability path touched. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - None of the listed pressure points were touched. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app/runtime, step by step. If an AI agent filled this out, verify it yourself before ticking boxes. --> Local validation run before opening the PR: - `pnpm vitest run src/engine/agents-runtime/executor/agent-executor.test.ts` - `pnpm vitest run src/engine/agents-runtime/executor/agent-executor.test.ts src/engine/generation/agent-runner.test.ts src/engine/agents-runtime/debug.test.ts` - `pnpm typecheck` - `pnpm check:architecture` - `pnpm test` - 39 files, 243 tests passed - `git diff --check origin/refactor...HEAD` - `git merge-tree $(git merge-base HEAD origin/refactor) HEAD origin/refactor` after fetching `origin/refactor`; no merge conflict markers reported. PR checks observed after opening the draft: - Frontend, Architecture, and Organization passed. - Rust Capability Layer passed. - Browser Smoke and Performance passed. - Auto-label passed. - CodeRabbit reported success with review skipped. No browser or native Tauri manual verification was run because this change is isolated to React-free engine executor behavior and covered by focused unit tests. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims No docs or release-note updates were made. This changes internal agent failure semantics and adds focused executor coverage; no public command, UI workflow, architecture guidance, or release claim changed. ## UI evidence <!-- Add before/after screenshots or recordings for visible UI changes. --> N/A - no visible UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added comprehensive test coverage for agent execution and batch operations, including error handling and retry scenarios. * **Bug Fixes** * Improved error detection for malformed agent responses with clearer error reporting. * Enhanced batch execution reliability with targeted retry logic for individual agent failures. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1416?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:13:03 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5081
No description provided.