Skip to content

docs(proposals): add agent judge skill proposal - #138

Merged
roark47 merged 2 commits into
feat/multi-turn-conversationfrom
codex/sup-0002-agent-judge-skill
Jul 7, 2026
Merged

roark47 merged 2 commits into
feat/multi-turn-conversationfrom
codex/sup-0002-agent-judge-skill

Conversation

@roark47

@roark47 roark47 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add SUP-0002 in English for judge-specific Skill support in agent_judge.
  • Add the matching Chinese SUP-0002 document with language links.
  • Update the proposals index with the new bilingual proposal entry.

Notes

The proposal covers judge Skill configuration, Agent-specific installation behavior, progressive loading, mandatory judge Skill usage in the AgentJudge prompt, isolation from the run agent, and report metadata.

Validation

  • make verify
  • make test

@roark47
roark47 marked this pull request as ready for review July 7, 2026 07:56
@roark47
roark47 requested a review from hittyt as a code owner July 7, 2026 07:56
@roark47
roark47 requested review from Copilot and zpzjzj July 7, 2026 07:56
@roark47 roark47 self-assigned this Jul 7, 2026
@roark47 roark47 added the documentation Improvements or additions to documentation label Jul 7, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a47786ba6

ℹ️ 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".

- "Grade whether the answer identifies high-risk issues according to the security judge Skill"
```

When a case declares its own `judge.type`, the case-level judge config is treated as a complete judge strategy: `skills` and `criteria` come from the case, while `model`, `pass_threshold`, and `timeout_seconds` can still inherit from global defaults.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Align validation with inherited case judge models

This scenario shows a case-level agent_judge that omits model and says it inherits from the global defaults, but the current validation path calls ValidateCaseConfig on each raw case before judge.MergeJudgeConfig (internal/config/validator.go:228-235), and validateJudgeTypeAndFields rejects agent_judge with an empty model (internal/config/validator.go:175-177). Unless the proposal explicitly changes validation to operate on the merged judge config, following this example will fail skill-up validate instead of inheriting the global model.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. I updated the proposal to make this explicit: validation that depends on inherited judge defaults, especially the required agent_judge model, must run against the effective config after judge.MergeJudgeConfig(global, caseLevel). Raw case validation can still handle case-local constraints, but it should not reject this inherited-model scenario. This keeps the existing runtime merge semantics and avoids broadening behavior beyond the documented inheritance path.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds SUP-0002 (EN + ZH) proposing agent_judge-scoped judge Skill support, and updates the proposals index to include the new bilingual entry.

Changes:

  • Added English SUP-0002 proposal describing judge.skills for agent_judge.
  • Added matching Chinese SUP-0002 proposal with language cross-links.
  • Updated proposals index to list SUP-0002.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
proposals/0002-agent-judge-specific-skill.md New English proposal detailing judge-specific Skill configuration, isolation, install flow, and reporting.
proposals/zh/0002-agent-judge-specific-skill.md New Chinese translation of SUP-0002 with cross-links and mirrored structure.
proposals/README.md Adds SUP-0002 row to the proposals index table.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- [Requirements](#requirements)
- [Proposal](#proposal)
- [User Scenario Quick Reference](#user-scenario-quick-reference)
- [Notes/Constraints/Caveats](#notesconstraintscaveats)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. Renamed the heading to Notes, Constraints, and Caveats and updated the ToC anchor to avoid relying on the slash-stripping slug.

@zpzjzj zpzjzj 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.

LGTM

@roark47
roark47 merged commit b32b7c8 into feat/multi-turn-conversation Jul 7, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in skill-up project Jul 7, 2026
roark47 added a commit that referenced this pull request Jul 8, 2026
…ing (#136)

* feat(config): add multi-turn conversation schema fields and validation

Add schema types and validation rules for multi-turn conversation evaluation:

Schema changes (internal/config/schema.go):
- Turn.Capture []CaptureRule for variable extraction from responses
- Turn.TimeoutSeconds for per-turn timeout control
- PostCondition.MustContainAll and MustNotContain fields
- CaptureRule type (Variable, Pattern, JSONPath)
- TurnResponseContainsRule, TurnResponseNotContainsRule
- ToolCalledInTurnRule, ToolNotCalledInTurnRule
- Rule struct extended with 4 per-turn assertion fields

Validation changes (internal/config/validator.go):
- Reject ambiguous input.prompt + input.turns combination
- Enforce input.turns[*].role must be "user"
- Validate post_condition.on_fail enum (fail, skip_remaining)
- Require at least one check in post_condition
- Validate capture variable identifier pattern
- Enforce exactly one extractor per capture rule
- Compile-time regex validation for capture patterns
- Per-turn judge rules: turn number range checks
- Required fields for turn_response_contains/not_contains
- Required name for tool_called_in_turn/tool_not_called_in_turn

All existing tests pass unchanged (backward compatible).

* feat(agent): add SessionResumer interface for multi-turn conversation

Introduce SessionResumer optional interface and SessionResult.SessionID field
to support multi-turn conversation evaluation:

Interface (internal/agent/agent.go):
- SessionResult.SessionID string field for session tracking across turns
- SessionResumer interface with RunTurn method
- Compile-time satisfaction checks for ClaudeCodeAgent, QoderCLIAgent

ClaudeCodeAgent (internal/agent/claude_code.go):
- Run populates SessionResult.SessionID from generated UUID
- RunTurn: empty sessionID delegates to Run (first turn)
- RunTurn: non-empty sessionID uses --resume flag
- buildClaudeResumeCmd for session resume commands
- Extract claudeRunEnvVars and handleClaudeRunResult helpers

QoderCLIAgent (internal/agent/qodercli.go):
- buildSessionResult extracts SessionID from session JSONL filename
- RunTurn: empty sessionID delegates to Run (first turn)
- RunTurn: non-empty sessionID uses -r flag
- buildQoderResumeCmd for session resume commands

Utilities (internal/agent/session_lookup.go):
- extractSessionIDFromPath strips directory and extension

All existing tests pass unchanged (backward compatible).

* feat(evaluator): add multi-turn conversation execution engine

Implement the evaluator multi-turn engine that orchestrates per-turn
agent execution with post-condition gates, variable capture, and
template substitution:

Types (internal/evaluator/multiturn.go):
- TurnStatus: completed, skipped, failed, error
- TurnResult: per-turn outcome with response, transcript, captured vars
- multiTurnState: mutable state for the multi-turn loop

Engine (internal/evaluator/multiturn.go):
- executeMultiTurn: main loop — template substitution, agent invocation,
  post-condition evaluation, variable capture, result aggregation
- executeSingleTurn: per-turn timeout + resumer invocation
- buildTurnResult: construct TurnResult from agent SessionResult
- handlePostCondition: on_fail=fail (abort) / skip_remaining (mark rest)
- evaluatePostCondition: must_contain_all/any, must_not_contain checks
- captureVariables: regex named group (?P<value>...) or first group
- substituteTemplate: {{variable}} replacement with unresolved error
- buildAggregateResult: merge per-turn metrics into final SessionResult
- multiTurnStatus: derive case status from turn outcomes

Integration (internal/evaluator/evaluator.go):
- EvalResult.TurnResults []TurnResult field for per-turn data
- executeCaseOnce branches to multi-turn when len(turns)>1 AND agent
  implements SessionResumer; non-resumer agents fall through to the
  existing batch Run path (backward compatible)

Tests (internal/evaluator/multiturn_test.go):
- TestSubstituteTemplate (6 cases)
- TestEvaluatePostCondition (8 cases)
- TestCaptureVariables (6 cases)
- TestMultiTurnStatus (5 cases)
- TestExecuteMultiTurn_HappyPath
- TestExecuteMultiTurn_PostConditionFail
- TestExecuteMultiTurn_PostConditionSkipRemaining
- TestExecuteMultiTurn_TemplateSubstitution
- TestExecuteMultiTurn_AgentError
- TestExecuteMultiTurn_NoResumer
- TestExecuteMultiTurn_UnresolvedTemplate

* feat(evaluator): strengthen post_condition and capture semantics

Post Conditions:
- extractCaptureValue rejects multiple unnamed capture groups (requires
  exactly one or a named group 'value')

Capture Variables:
- Add comprehensive test coverage for edge cases: multiple unnamed groups
  error, case-sensitivity in post_condition matchers, named group priority

Tests:
- TestCaptureVariables_EdgeCases: multi-group error, named+unnamed priority
- TestPostConditionCaseSensitivity: explicit case-sensitive assertion
- TestExtractCaptureValue: unit tests for the extraction helper
- Split long test functions to satisfy funlen linter (80 stmt limit)

Lint:
- Replace fmt.Errorf (no formatting) with errors.New
- gofumpt formatting fixes

* feat(judge): add per-turn assertion rules for multi-turn evaluation

Judge Input:
- Add InputTurnResult type with TurnNumber, Content, Response,
  Transcript, Status, and Reason fields
- Add TurnResults []InputTurnResult field to judge.Input

Per-turn rule evaluators (internal/judge/rule_based.go):
- turn_response_contains: check contains_all/contains_any on a
  specific turn's response
- turn_response_not_contains: check forbidden keywords absence
- tool_called_in_turn: verify tool usage with optional partial args
- tool_not_called_in_turn: verify tool absence in a turn
- Shared lookupTurn helper: validates turn existence and completed
  status before content assertions

Evaluator wiring (internal/evaluator/evaluator.go):
- Add toJudgeTurnResults converter from evaluator.TurnResult to
  judge.InputTurnResult
- Pass TurnResults in judge.Input within evaluateCaseSession

Tests:
- 16 new test cases covering all 4 per-turn rules: positive/negative
  matching, missing turns, skipped turns, failed turns, args matching
- Table-driven patterns to satisfy dupl linter

* feat(report): add per-turn results to report output formats

CaseResult (internal/report/reporter.go):
- Add TurnResults []CaseTurnResult field (omitempty for backward compat)
- Define CaseTurnResult with TurnNumber, Content, Response, Status, Reason

JSON report:
- turn_results automatically serialized in result.json/report.json
- Omitted for single-turn cases (nil slice + omitempty)

HTML report (internal/report/html.go):
- Add embeddedTurn type and TurnResults field to embeddedCase
- caseTurnResultsToEmbedded converts report types to embedded JS data

JUnit report (internal/report/junit.go):
- buildFailureBody appends non-completed turn status/reason lines
- Turn-scoped assertion texts already contain turn numbers for CI

Runner wiring (internal/runner/runner.go):
- evalResultToCaseResult passes TurnResults via evalTurnResultsToReport
- Converter maps evaluator.TurnResult to report.CaseTurnResult

* docs: add multi-turn conversation documentation and update e2e examples

writing-evals.md (EN + ZH):
- New 'Multi-turn conversations' section covering input.prompt vs
  input.turns decision matrix, post_condition gate semantics,
  capture/template variable syntax, agent support matrix, and
  per-turn judge assertion examples.

e2e/testdata/multi-turn-conversation:
- phase-gate-skip-attempt.yaml: convert fake single-prompt to real
  input.turns with post_condition + turn_response_contains assertions.
- multi-turn-refinement.yaml: split into 2 real turns with capture
  and per-turn assertions.

skills/skill-upper:
- references/case-yaml.md: expand multi-turn section with capture
  field reference and per-turn judge assertion examples.
- assets/case.yaml.tmpl: add capture and per-turn judge commented
  examples.

CHANGELOG.md:
- Add [Unreleased] entries for multi-turn conversation feature,
  per-turn assertions, session resumption, and report TurnResults.

* feat(agent): implement SessionResumer for Codex engine

CodexAgent now implements the SessionResumer interface, enabling native
multi-turn conversation support via `codex resume <thread-id>`.

codex.go:
- Add RunTurn method: first turn (sessionID=="") delegates to Run;
  subsequent turns build a `codex resume --json` command with the
  thread ID obtained from the first turn's event stream.
- Set SessionResult.SessionID = streamParsed.threadID in buildSessionResult
  so the evaluator can pass it forward between turns.
- Add buildCodexResumeCmdWithLastMessage helper (mirrors the exec variant
  but uses `codex resume` subcommand with sessionID positional arg).

codex_test.go:
- TestCodexRunTurn_FirstTurnDelegatesToRun: verifies first turn uses
  `codex exec` and extracts thread ID into SessionID.
- TestCodexRunTurn_ResumeUsesCorrectCommand: verifies subsequent turns
  use `codex resume` with the session ID and instruction.
- TestBuildCodexResumeCmdWithLastMessage: unit test for command builder.

Docs: update agent support matrix in writing-evals.md (EN+ZH) and
CHANGELOG.md to reflect Codex multi-turn support.

* fix(agent): use codex exec resume for non-interactive session resumption

The top-level 'codex resume' command is a TUI-only subcommand that does
not support --json, --skip-git-repo-check, or --output-last-message.

Switch to 'codex exec resume' which is the non-interactive equivalent
supporting all required flags. Remove the --sandbox flag from resume
commands since the session inherits sandbox settings from its initial
creation; use --dangerously-bypass-approvals-and-sandbox to ensure
non-interactive execution.

* fix(judge): include rule keywords in assertion evidence

When assertions pass, the evidence field now includes the actual
keywords that were checked, making it possible to audit results
without referring back to the case YAML.

- turn_response_contains: evidence shows contains_all/contains_any lists
- turn_response_not_contains: evidence shows the forbidden keywords list
- output_contains: evidence shows all/any/not keyword lists

* fix(evaluator): proceed to judge on skip_remaining post-condition failure

multiTurnStatus previously treated all TurnFailed results as hard
failures, skipping judge execution entirely. This broke the
on_fail=skip_remaining contract which is designed to skip subsequent
turns but still run the judge on whatever data was collected.

Distinguish the two modes by checking whether TurnSkipped entries
follow the failed turn — if so, it is a skip_remaining case and
the evaluator proceeds to judge evaluation.

* fix(report): render multi-turn conversation and failure reasons in HTML

- Show per-turn Prompt/Response cards when turn_results is available,
  replacing the previous single prompt/response view
- Synthesize FORMAL GRADES from turn post-condition failures when the
  judge was not executed (grading is null but turn_results has failures)
- Hide the top-level Prompt section for multi-turn cases to avoid
  showing only the first turn's content

* chore: ignore local verification project directory

* chore: Update changelog

* fix(evaluator): correct multi-turn execution accounting

* fix: address copilot multi-turn review feedback

* docs(proposals): add agent judge skill proposal (#138)

* docs(proposals): add agent judge skill proposal

* docs(proposals): address agent judge skill review

* ci: run workflows on self-hosted runners

* test: skip git-dependent tests without git

* fix: improve caching strategy for buildx in GitHub Actions

* ci: stop using gha build cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants