Skip to content

fix(opencode-agents): skip judges and record structured history - #177

Open
apucacao wants to merge 2 commits into
mainfrom
cursor/opencode-judge-span-a60f
Open

apucacao wants to merge 2 commits into
mainfrom
cursor/opencode-judge-span-a60f

Conversation

@apucacao

@apucacao apucacao commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Judges still match this handler because provides_for stays ("*", "agent"). A judge evaluation now raises before events() runs, so the judge prompt does not open the OpenCode session and the judge does not score.

_input_messages records block-array history on the invoke_agent span, using the same text flattening as the other handlers, and does not append an empty user_input.

provides_for is unchanged. This does not change #159.


Note

Overview
The OpenCode handler now detects judge evaluations via OpenTelemetry context and raises before events() runs, so a judged config does not reopen the OpenCode session on the judge prompt or produce a bogus score. Callers can still use skip_judges=True on config() to avoid selecting a judge attempt entirely. Docs and examples no longer treat skip_judges=True as required for normal agent streaming.

_input_messages now builds invoke_agent span input with compose_history and content_to_text, matching other handlers: block-array turns are flattened to text, system messages are omitted from gen_ai.input.messages, and an empty user_input does not add a blank user turn.

Tests cover judged streaming (events called once, no judge_results) and block-array history on the span.

Reviewed by Cursor Bugbot for commit e54111d. Bugbot is set up for automated code reviews on this repo. Configure here.

provides_for stays ('*', 'agent'), so judge selection still lands here.
A judge evaluation raises before events() runs, and the judge does not score.
_input_messages kept only string history and always appended user_input,
so structured history never reached invoke_agent and an empty turn did.
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.

2 participants