Skip to content

feat(tier3): rebuild ATIF from OpenCode and Codex agent logs - #119

Merged
rng1995 merged 28 commits into
NVIDIA:mainfrom
mimran-khan:feat/opencode-atif-fallback
Oct 4, 2026
Merged

rng1995 merged 28 commits into
NVIDIA:mainfrom
mimran-khan:feat/opencode-atif-fallback

Conversation

@mimran-khan

Copy link
Copy Markdown
Contributor

Fixes #118

When Harbor leaves trajectory.json empty, Tier 3 scoring used to fail with "No trajectory or reconstructible agent log" even though OpenCode and Codex tee structured JSON to opencode.txt and codex.txt.

This adds parsers for OpenCode run --format=json events (text + completed tool_use records) and wires them into load_trajectory_with_fallback after the existing claude/cursor/cline fallbacks. Codex reuses the same parser when every tee line is JSON. Non-dict tool inputs are ignored so raw strings are not treated as shell commands.

Harbor task bundles already copy log_converters.py through adapter.py, so generated verifiers pick this up automatically.

Distinct from #110, which is about exec steps inside an existing trajectory.

Test plan

  • pytest tests/tier3/test_log_converters.py
  • pytest tests/test_harbor_collector_runtime_failures.py

Parse OpenCode JSON stream events into synthetic trajectories when
trajectory.json is empty, and reuse the parser for structured Codex tee
logs. Fail closed on non-dict tool inputs.

Fixes NVIDIA#118

Signed-off-by: mimran-khan <[email protected]>
Codex tee logs use type=item / agent_message events, not OpenCode tool_use.
Add a dedicated parser with stderr-tolerant JSONL scanning, keep OpenCode-shaped
JSONL as a fallback, and normalize shell calls to bash for skill checks.

Signed-off-by: mimran-khan <[email protected]>
@mimran-khan

Copy link
Copy Markdown
Contributor Author

Codex parser fixes are pushed from the earlier round. Ready for re-review when you have time.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current head still does not reconstruct real Codex exec events, and the new OpenCode fallback is not connected to the collected-results discovery path. Focused converter and refinement tests passed (95 tests), with Ruff and diff checks clean. Requesting changes for the two reproducible integration gaps noted in the review threads.

…ries

Merge main and handle Codex exec JSON item.completed events with agent_message
text and command_execution items. Include opencode in trajectory discovery so
refinement can rebuild ATIF from opencode.txt when trajectory.json is missing.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three earlier integration issues are fixed and their threads are resolved. The focused converter/refinement suite passes (36 tests), with Ruff and diff checks clean. Two correctness gaps remain: Codex terminal status, exit code, and some error forms are discarded, and OpenCode failures that include partial output lose both failed status and error details. These make failed actions indistinguishable from successful empty or partial-output actions in downstream evidence, so I am requesting changes on the two remaining threads.

rng1995 and others added 3 commits September 12, 2026 00:32
Preserve exit code, status, and error evidence for failed command runs,
file changes, and MCP calls, and keep OpenCode error text alongside partial
output for downstream grading.

Signed-off-by: mimran-khan <[email protected]>
Keep Harbor trial discovery tests from main and restore OpenCode trajectory
fixtures from this branch.

Signed-off-by: mimran-khan <[email protected]>
@mimran-khan

Copy link
Copy Markdown
Contributor Author

Pushed b4644da with main merged in. Codex command_execution now keeps status, exit_code, and errors even when command is false or output is empty; file_change and MCP calls get the same terminal evidence, and OpenCode keeps status plus error text alongside partial output. Harbor trial discovery tests from main are in, plus the OpenCode trajectory fixtures on this branch. Happy to re-test anything specific.

@rng1995

rng1995 commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

@mimran-khan, two code blockers remain at 9630637:

  • A multi-file file_change attaches item-level status/error evidence only to the first generated write call, leaving later files indistinguishable from successful empty-result writes. Please attach the evidence to every emitted write call, or model the change as one transaction, and add a multi-file failure regression.
  • Long partial output can consume the 8,000-character observation limit before the error is appended, so the failure reason disappears. Please reserve space for or place terminal status/error evidence before truncating output, and add a long-output failure regression.

Please address both items and ping me when the PR is ready for re-review.

Merge main, prefer task_id.path for Harbor entry ids, recognize Codex
terminal status in error recovery, and synthesize web_search thread items.

Signed-off-by: mimran-khan <[email protected]>
@mimran-khan

Copy link
Copy Markdown
Contributor Author

@chrisknvidia follow-up on todays three threads: 618e4300 is on the branch with merged main. (1) task_id.path wins over prefixed task_name for Harbor entry ids. (2) error recovery recognizes status=failed / exit_code= from Codex observations. (3) web_search thread items are synthesized into tool calls. Regressions in test_harbor_result_entry_id.py and test_log_converters.py.

@rng1995

rng1995 commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

@mimran-khan Let us know when you have addressed the final round of review comments present in PR. Post that, I can help merge the changes. Thanks for your contributions!

@mimran-khan

mimran-khan commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor Author

@mimran-khan Let us know when you have addressed the final round of review comments present in PR. Post that, I can help merge the changes. Thanks for your contributions!

Missed the last update for some reason, let me take a look. @rng1995 : thanks for the nudge

mimran-khan and others added 2 commits September 17, 2026 04:21
Merge main and synthesize WebSearchItem action payloads plus
collab_tool_call thread items into ATIF with schema-shaped fixtures.

Signed-off-by: mimran-khan <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mimran-khan — Re-reviewed current head 8063d5b. The earlier Codex/OpenCode integration, Harbor case-id, terminal-evidence, bounded-output, and downstream error-recovery findings are fixed; their verified threads are resolved. Local verification is otherwise clean: changed-file Ruff passes, focused converter/refinement tests are 53/53, the broader Tier 3 suite is 1,235 passed, and git diff --check is clean. Two schema correctness blockers remain in the existing unresolved threads: (1) schema-valid multi-query web_search events lose the action type and queries from ATIF arguments, while the new fixtures omit required wire fields and add non-wire status; (2) schema-valid collab_tool_call events lose sender_thread_id, receiver_thread_ids, and agents_states, and the new fixture does not exercise them. These can silently remove source-retrieval and delegated-agent evidence, so I am requesting changes. The newest fork workflows also remain at the separate action_required authorization gate.

@rng1995

rng1995 commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

@mimran-khan - Can you address the remaining review comments presented here: #119 (review) so that we can merge the MR?

Keep the full WebSearchItem action payload (including multi-query
searches) and map CollabToolCallItem sender/receivers/agents_states
with schema-valid fixtures.

Signed-off-by: mimran-khan <[email protected]>
@mimran-khan

Copy link
Copy Markdown
Contributor Author

@rng1995 addressed the remaining schema blockers from #119 (review) at 0a5aa8f9 (merged latest main). Web search keeps the full action payload including multi-query queries, and collab tool calls keep sender/receivers/agents_states. Ready for re-review whenever you have a moment.

mimran-khan and others added 3 commits September 30, 2026 22:43
Emit metadata.exit as exit_code= in OpenCode observations and treat any
nonzero exit as a failure in both error-recovery checkers.

Signed-off-by: mimran-khan <[email protected]>
Resolve CHANGELOG conflict after NVIDIA#100 landed on main.

Signed-off-by: mimran-khan <[email protected]>
Resolve the CHANGELOG conflict after the 0.4.0 release on main: main
moved the `--no-llm` entry out of 0.3.0 into 0.4.0, so drop it from
0.3.0. Move this branch's unreleased entries (log converters, Harbor
result.json case ids, Codex log synthesis) from the released 0.3.0
section into the new Unreleased section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mimran-khan Thank you for your patience through a long review, and for your contribution to SkillEvaluator!

I re-reviewed 4194d8a against the upstream Codex exec_events.rs schema. All three remaining threads are fixed:

  • Codex web_search: action_input keeps the required top-level query and the full action object. Multi-query search keeps type and queries, open_page keeps url, and find_in_page keeps url and pattern. The fixtures now use the real event shape.
  • Codex collab_tool_call: tool, sender_thread_id, receiver_thread_ids, prompt, agents_states and status all reach ATIF, and the fixture checks every field.
  • OpenCode exit codes: a completed bash call with a nonzero metadata.exit keeps exit_code=N in the observation. Both error-recovery checkers (eval_core and the Harbor template) now treat it as a failure, so a failed command followed by a retry no longer scores as "All commands succeeded on first attempt".

Each new regression test fails on the code from before its fix and passes at head. Ruff passes, the full suite passes (9,538 passed, 18 skipped), and all 17 CI checks are green.

Before this can merge, the CHANGELOG.md conflict with main needs resolving. main released 0.4.0, so this PR's entries belong under ## Unreleased. That is the only conflict, and the code merges cleanly.

Non-blocking follow-ups for a later PR:

  • exit_code=-1 doesn't match the nonzero-exit pattern, so a failure with that code still counts as a clean first attempt.
  • Upstream Codex now emits WebSearchItem.results, and the converter reads only result.

Approved.

@rng1995
rng1995 merged commit 40357d7 into NVIDIA:main Oct 4, 2026
17 checks passed
rng1995 added a commit to kweinmeister/SkillEvaluator that referenced this pull request Oct 4, 2026
Resolve the collector.py conflict with NVIDIA#119, which made Harbor result.json
case ids prefer the canonical task_id.path directory over repository-prefixed
task_name values. Keep this branch's _resolve_harbor_result_entry_id
(metadata.entry_id from the task path, staged-name map, arm-suffix handling)
and apply NVIDIA#119's rule inside it: when the result carries a task path that has
no metadata.entry_id or map entry, return the directory name before falling
back to task_name.

This also keeps a valid dual-arm set with directory y (with [task]) next to
y-with-skill (no [task]) from being collected under y.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
chrisknvidia added a commit that referenced this pull request Oct 30, 2026
* feat(tier3): rebuild ATIF from OpenCode and Codex agent logs

Parse OpenCode JSON stream events into synthetic trajectories when
trajectory.json is empty, and reuse the parser for structured Codex tee
logs. Fail closed on non-dict tool inputs.

Fixes #118

Signed-off-by: mimran-khan <[email protected]>

* fix(tier3): parse Codex exec --json JSONL for ATIF fallback

Codex tee logs use type=item / agent_message events, not OpenCode tool_use.
Add a dedicated parser with stderr-tolerant JSONL scanning, keep OpenCode-shaped
JSONL as a fallback, and normalize shell calls to bash for skill checks.

Signed-off-by: mimran-khan <[email protected]>

* fix(tier3): address OpenCode/Codex ATIF and Harbor trial id gaps

Resolve trial case ids from reward/result metadata before refine lookup.
Parse Codex file_change and mcp_tool_call events, and keep OpenCode tool
failures in observations via state.error.

Signed-off-by: mimran-khan <[email protected]>

* fix(tier3): retain terminal status in Codex and OpenCode logs

Preserve exit code, status, and error evidence for failed command runs,
file changes, and MCP calls, and keep OpenCode error text alongside partial
output for downstream grading.

Signed-off-by: mimran-khan <[email protected]>

* fix(tier3): preserve terminal evidence in bounded observations

Attach file-change status to every write call, and trim long tool output
without dropping status or error text.

Signed-off-by: mimran-khan <[email protected]>

* fix(tier3): preserve Codex web_search and collab wire fields

Keep the full WebSearchItem action payload (including multi-query
searches) and map CollabToolCallItem sender/receivers/agents_states
with schema-valid fixtures.

Signed-off-by: mimran-khan <[email protected]>

* fix(tier3): preserve OpenCode bash exit codes for error recovery

Emit metadata.exit as exit_code= in OpenCode observations and treat any
nonzero exit as a failure in both error-recovery checkers.

Signed-off-by: mimran-khan <[email protected]>

---------

Signed-off-by: mimran-khan <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Co-authored-by: Christopher Kevin <[email protected]>
Co-authored-by: Narendran Raghavan <[email protected]>
Co-authored-by: Narendran Raghavan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA]: Reconstruct ATIF trajectories from OpenCode and Codex agent logs

3 participants