Repository navigation
fix: normalize string tool results and preserve start-failure handles - #11
Conversation
Proven against real ChatGPT Desktop (macOS) in a Tart VM lab: codex_app__create_thread returns its whole payload as a JSON string, so key lookups on the raw return silently fail, converting every successful start into a start failure and blocking the graph while the created threads keep running unobserved (live_handles reported []). - references: mandate exact-envelope normalizeToolResult at the call boundary (no fragment heuristics on tool returns; raw kept in start_result), make pending-setup resolution non-optional including projectless targets, and require aggregate start errors to carry every rejected node's handle into the blocked result - validator guidance: decode HTML entities before URL comparison so & vs & does not consume the single repair allowance - harness: add normalizeToolResult, aggregateStartFailure, canonicalUrlForComparison with regression coverage (10/10)
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe change adds helpers for tool-result normalization, startup failure aggregation, and URL canonicalization. Lifecycle guidance now preserves live handles from rejected starts, resolves pending setup tasks, and verifies stringified tool results. ChangesTask lifecycle robustness
Estimated code review effort: 2 (Simple) | ~15 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…hannel
Review feedback on the call-boundary example: drop the lastRawToolResult
global; call returns { value, raw } and the start site stores raw in
handle.start_result directly. Deduplicate the normalization rule - the
code and full contract live in code-mode-script-patterns.md; the task
lifecycle reference now points at it instead of repeating the block.
Matches the shape a freshly generated candidate adopted in the lab
(frozen-v3, executed to status passed).
call now returns { value, raw }; use value.value for agent ID
lookup and value.raw for spawnResult, matching the start-site pattern.
Wire normalizeToolResult into both resolveTool call paths so the
canonical helper returns the {value,raw} envelope. Make findExactThread
require projectId only when one is bound so projectless pending setup
can resolve on the unique run tag.
Collection must read wait/read fields from the normalizeToolResult value, not the envelope. Required parallel starts create each handle first and rethrow with it attached so aggregate failures can preserve live handles.
Pending-setup polling matches on handle.project_id; omit it and project-bound workflows can bind the wrong thread or under-report.
…es (#16) * feat: dynamic-workflow golden test cases from real Grok/Claude orchestration shapes Turn curated Grok Rhai workflows (destination/hotel discovery funnels, fixed-lane research DAGs) and Claude multi-agent patterns (disjoint worktree implementers, review-scorer panels) into a maintainable codex-graph test-case pack: - docs/dynamic-workflow-testcase-catalog.md: source survey, shape analysis, tier/contract mapping, prioritized shortlist - skills/codex-graph/testcases/: catalog.json + six case bundles (GOAL.md, EXPECTATIONS.md with fenced machine contract, topology.hint.mmd passing graph_coherence.py) - testcases/harness/: offline expectations loader + static workflow.js checker (per-node env #14, read-first collection #13, node-local prompt scoping #12, result normalization #11) with CLI and 15 tests - task_collection_harness.test.js: three pattern-derived fixtures (atomic screen fan-out terminal-at-first-read, screen-then-POV staged cardinality with root-owned fail-open, adversarial dual validators failing closed on malformed verdicts) - both regression runners execute the new suite and lint the hints Goals are synthetic and anonymized; no live Desktop run required. * fix: harden expectations checker per PR #16 review - collection:read-first / read-after-wait judge await-adjacent call sites only; parameter lists, bindings, and comments can no longer flip the verdict (v3 param-swap now fails; wrapper-based correct collectors are no longer false-failed) - setup:pending-resolution requires bounded-resolution evidence (attempts constant or task-list poll) alongside the clientThreadId identifier; mentions-only scripts fail - checkWorkflowText refuses vacuous ok on an empty contract - atomic-screen-fanout goal genericized (composition/origin/month) - disjoint-writers-worktree contract declares its drawn repair path (single_repair, R1, V2) - four new negative/positive controls in testcases.test.js; README semantics updated to match the strengthened checks * fix: fail collection checks when read/wait tools are absent Await-adjacent matching correctly skips wrapper collectors, but treated scripts with no read/wait bindings the same way and green-lit #13. Require tool bindings when there are no await-adjacent call sites. --------- Co-authored-by: Cursor Agent <[email protected]>
Lab evidence (jnyross/mac-vm-testing-harness, branch codexgraph-vm-test @ 33777c7, worktree ~/Projects/mac-vm-harness--codexgraph-test)
Frozen candidate v1 (generated by the shipped skill, SHA-256 c891048a..., executed unchanged in ChatGPT Desktop Code Mode): all three feed workers 'failed to start' -> status blocked with live_handles [] while the three created threads kept running. Root cause proven by typeof diagnostic: the Code Mode tool returns its entire payload as a JSON string ({"threadId":...,"hostId":"local"}), and the generated findString key lookup cannot see into a string.
Frozen candidate v2 (v1 + exactly the two fixes in this PR, SHA-256 0debc233...): full 9-node pipeline executed on live feeds - D1-D3 fetch, I1 join, V1 gate, R1 repair, V2 revalidation, honest X1 terminal with digest_markdown, repair_used true, correct node accounting.
Changes
Not claiming the product fully proven: the passed-status happy path with a regenerated (not hand-patched) script is the next scenario (Phase B).
Note
Low Risk
Documentation and test-harness changes for Code Mode orchestration patterns; no production runtime or auth/data paths.
Overview
Fixes Code Mode graph scripts misclassifying successful task starts and losing live tasks when parallel starts fail.
Tool result handling:
resolveTooland direct tool calls now wrap returns withnormalizeToolResultso JSON string payloads (e.g.codex_app__create_threadon Desktop) are parsed once into{ value, raw }for ID lookup whilestart_resultkeeps the raw envelope—without fragment-extraction heuristics meant for model prose.Start / blocked reporting: Required parallel starts build handles before each call, attach per-node handles on rejection, and aggregate failures with
error.handlesfor blockedlive_handles. Pending setup resolution is mandatory (including projectless targets via run tag only);findExactThreadskips project ID matching when no project is bound.Validators: Documents
canonicalUrlForComparisonso&/ numeric entities do not trigger the single repair stage for equivalent URLs.Harness: Exports
normalizeToolResult,aggregateStartFailure, andcanonicalUrlForComparisonwith unit tests for string parsing, handle preservation, and URL normalization.Reviewed by Cursor Bugbot for commit 3f5e6a5. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Bug Fixes
Documentation
Tests