Repository navigation
fix(reflection): reject unsuccessful embedded terminal results - #1011
Conversation
rwmjhb
left a comment
There was a problem hiding this comment.
PR #1011 Review: fix(reflection): reject unsuccessful embedded terminal results
Verdict: APPROVE | 6 rounds completed | Value: 58% | Size: MEDIUM | Author: igs-rogenlo
Value Assessment
Problem: Embedded reflection runs can resolve with failure metadata and visible error or partial text, which the current code can accept as a successful reflection. This can store host error messages or incomplete output instead of useful reflection content.
| Dimension | Assessment |
|---|---|
| Value Score | 58% |
| Value Verdict | review |
| Issue Linked | true |
| Project Aligned | true |
| Duplicate | false |
| AI Slop Score | 0/6 |
| User Impact | medium |
| Urgency | medium |
Open Questions:
- Does #995 have maintainer acknowledgment? The supplied linked record has no labels, assignment information, or maintainer comments establishing it.
- Given the stale-base signal, has current main or another open PR already addressed terminal-result rejection?
- Do supported host contracts confirm the failure metadata shapes used here, particularly the meaning of payload-level isError?
Summary
Embedded reflection runs can resolve with failure metadata and visible error or partial text, which the current code can accept as a successful reflection. This can store host error messages or incomplete output instead of useful reflection content.
Evaluation Signals
| Signal | Value |
|---|---|
| Blockers | 0 |
| Warnings | 0 |
| PR Size | MEDIUM |
| Verdict Floor | approve |
| Risk Level | high |
| Value Model | codex |
| Primary Model | codex |
| Adversarial Model | claude |
Nice to Have
- MR2: Thrown terminal-result errors may count toward the embedded runner's failure or circuit-breaker state
- MR4: The diagnostic drops the failure kind
Recommended Action
Ready to merge.
Reviewed at 2026-10-26T14:13:34Z | 6 rounds | Value: codex | Primary: codex | Adversarial: claude
Summary
An embedded reflection run can resolve normally while reporting a terminal failure in
meta.error,meta.aborted,modelFallbackStopReason, or anisErrorpayload. Reflection currently takes the first nonempty payload text, so a host timeout or error message can be returned as a successful reflection.Reject those unsuccessful terminal results before extracting reflection text, then use the existing tool-free completion or diagnostic fallback. This keeps successful results and older hosts that omit optional metadata working. It does not change runner selection, retries, configuration, permissions, or the fallback implementations.
Validation
aborted: false, structured errors, aborted results, timeout-only metadata, mixed partial/error payloads, legacy failures, legacy success without metadata, and normal false flags.dist/index.jsdiffers from the tracked output.Compatibility
The current
runEmbeddedAgent/legacy-name support from #995 remains unchanged. No minimum host version or schema change is introduced. This patch only addresses failed terminal-result interpretation; it does not claim full equivalence with other downstream reflection customizations.Additional pinned-upstream retest — 2026-11-05
The official development branch remains
c0e2c7a3a8b5780b6133ddfd9e2f426bf0ea1b6c. Carrying the regression fixture onto that source produces 6 failing regressions / 11 passing controls before this fix, and 17/17 passing tests with the fix. The tests load the real plugin implementation with synthetic host callbacks and the SDK test fixture; they are not Gateway or live-provider acceptance.The published npm stable 1.0.32 does not contain this reflection-runner implementation. This is a fix for the development/beta reflection path, not a demonstrated defect in that stable release. Current deployment-specific native-adapter checks are separate and are not used to claim that production naturally exercised this PR's legacy path. No additional deployment or upstream merge is claimed.