Skip to content

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

Open
mimran-khan wants to merge 15 commits into
NVIDIA:mainfrom
mimran-khan:feat/opencode-atif-fallback
Open

feat(tier3): rebuild ATIF from OpenCode and Codex agent logs#119
mimran-khan wants to merge 15 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 <mohammed_imran.khan@outlook.com>
Comment thread src/skillevaluator/tier3/eval_core/log_converters.py
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 <mohammed_imran.khan@outlook.com>
@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.

Comment thread src/skillevaluator/tier3/eval_core/log_converters.py

@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.
Comment thread src/skillevaluator/tier3/generate_dataset.py
steps.append(step)
continue

if item_type == "command_execution":

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.

[P1] Preserve the other completed Codex action items. The Codex 0.153.0 ThreadItem schema also emits file_change and mcp_tool_call, but this parser stops at agent messages and command_execution. A real 0.153.0 file-write run contained a completed file_change while this function produced no write call; a file/MCP write can therefore disappear from downstream file-change evidence, behavior grading, and trace-level security checks. Please map those action items into ATIF calls/observations, preserve status/error and command exit_code, and add captured current-CLI fixtures.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added parsing for Codex file_change and mcp_tool_call completed items in synthetic_trajectory_from_codex_json, with tests in test_log_converters.py. This sits alongside the existing command_execution and agent_message handling.

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 new file_change and mcp_tool_call types are mapped, but the requested terminal evidence is still dropped. On this head, a completed command_execution with command=false, exit_code=1, status=failed, and empty aggregated_output becomes a bash call with an empty observation and no exit code or status; file changes likewise omit status/error, and non-object MCP errors are ignored. Downstream grading cannot distinguish these failures from successful empty-output actions. Please preserve terminal status, exit code, and error evidence and add failure fixtures before this thread is resolved.



def _opencode_output_text(state: dict[str, Any]) -> str:
output = state.get("output")

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.

[P2] Keep failed OpenCode tool outcomes in the observation. OpenCode error events put the failure text in state.error rather than state.output, so this helper returns an empty string and the synthetic ATIF records the attempted call with no indication it failed. In a retained real OpenCode log, all 6 status=error calls became empty observations, leaving downstream recovery and accuracy evidence unable to distinguish failure from a successful call with no output. Please fall back to state.error when output is absent, retain the terminal status, and add an error-state fixture.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

_opencode_output_text now falls back to state.error when output is empty, so failed tool calls keep their failure text in the observation. Covered by test_opencode_tool_error_uses_state_error_observation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@chrisknvidia @rng1995 All three Sep 3 items are addressed at 05f7b62 (main merged, including #111). Fork CI needs approval before checks run. Ready for re-review when you have time.

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 error-text fallback works only when output is absent, but terminal status is still not retained. With state.status=error plus partial output and state.error, this head records only the partial output; both the error and failed status disappear. Please preserve the terminal status and error alongside any output, then cover this mixed-output failure case.

mimran-khan and others added 7 commits September 3, 2026 15:56
Signed-off-by: mimran-khan <mohammed_imran.khan@outlook.com>
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 <mohammed_imran.khan@outlook.com>
Signed-off-by: mimran-khan <mohammed_imran.khan@outlook.com>

@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 <mohammed_imran.khan@outlook.com>
Keep Harbor trial discovery tests from main and restore OpenCode trajectory
fixtures from this branch.

Signed-off-by: mimran-khan <mohammed_imran.khan@outlook.com>
@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.

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