fix(sdk-python): count opencode turns from JSON step events#546
fix(sdk-python): count opencode turns from JSON step events#546AbirAbbas merged 2 commits intoAgent-Field:mainfrom
Conversation
Performance
✓ No regressions detected |
📊 Coverage gateThresholds from
✅ Gate passedNo surface regressed past the allowed threshold and the aggregate stayed above the floor. |
📐 Patch coverage gateThreshold: 80% on lines this PR touches vs
✅ Patch gate passedEvery surface whose lines were touched by this PR has patch coverage at or above the threshold. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b10731bdb4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6e38e231a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
f6e38e2 to
804d189
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 804d1896da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
804d189 to
2aad82f
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Fixes
HarnessResult.num_turnsforprovider="opencode"in the Python SDK.Instead of reporting
1whenever text output exists, the provider now parses OpenCode JSON events and counts actual turns fromstep_startevents (with fallback behavior). Added regression coverage to ensure multi-step runs reportnum_turns > 1. This PR also hardens the newer JSON-stream path so OpenCode-specific output is handled correctly: assistant text is extracted fromtype:"text"part.textevents, multi-part text within a step is accumulated, per-step stream cost is preferred over prompt/completion estimation when available, and in-bandtype:"error"events are surfaced as real failures instead of falling through as empty success.Testing
./scripts/test-all.shAdditional verification (please describe):
python3 -m venv .venv && .venv/bin/python -m pip install -r sdk/python/requirements-dev.txt.venv/bin/python -m pytest sdk/python/tests/test_harness_provider_opencode.py -vChecklist
CHANGELOG.md(or this change does not warrant a changelog entry).Screenshots (if UI-related)
Not applicable (no UI changes).
Related issues
Fixes #518