Skip to content

Agentic maintenance for the model-routing golden test suite #67479

Closed

Description

@SivaKesava1

Background

#67253 (fixes #67250) adds golden tests under pkg/cli/testdata/model_routing_golden/. They contain five trimmed, sanitized routed runs in the downloaded-run layout. Each case has an expected.json and an expected.legacy.json, and logs_expected.json covers the gh aw logs aggregate. pkg/cli/model_routing_golden_test.go checks them all.

@pelikhan asked for an agentic way to maintain these goldens. They need updating whenever audit's routing or token-usage output changes. Today there are only two tools:

  • the UPDATE_MODEL_ROUTING_GOLDEN environment variable on go test, which regenerates the expected files;
  • an out-of-repo script, which produced the input fixtures and can't be reproduced in this repo.

Plan

1. make update-model-routing-golden

Add an update-model-routing-golden target to the Makefile, modeled on update-wasm-golden. It runs the TestModelRoutingGolden* tests in ./pkg/cli with UPDATE_MODEL_ROUTING_GOLDEN=1 to regenerate every expected.json, expected.legacy.json and logs_expected.json. Then it prints a diff summary of pkg/cli/testdata/model_routing_golden/ for review. Add the target to the make help listing next to update-wasm-golden.

2. Fixture-capture command

Add a capture tool: either a hidden gh aw subcommand in pkg/cli or a script under scripts/. It takes a run ID or run URL and a case name, downloads the run the same way gh aw audit does, and writes a new case directory under pkg/cli/testdata/model_routing_golden/. It should:

  • Keep only the files that audit's routing and token-usage analysis reads:
    • root and agent aw_info.json, plus usage/aw_info.json when present
    • agent/awf-routing-outcome.json
    • agent_usage.json and usage/agent_usage.json
    • usage/aw_session.jsonl and agent-session.jsonl
    • model-routing.jsonl and token-usage.jsonl under sandbox/firewall/logs/api-proxy-logs/
  • Filter session events. In session files, keep only:
    • session.*, workflow.info, model_routing.outcome, firewall.model_routing, firewall.token_usage, agent.execution and subagent.*
    • pi.subagent_* and, for pi, tool.execution_*
  • Redact sensitive content:
    • prompt, message, task and tool content
    • cwd, conversation hashes, signatures and encrypted content
    • org, repo and user names, which it replaces with placeholders
  • Preserve what the analysis depends on. Keep AWF credit fields intact, because audit validates them and falls back to price tables when they're missing or invalid. Also keep model IDs, endpoints, efforts, token counts and request IDs.
  • Verify the fixture. Run the routing and token-usage analysis on both the full download and the trimmed fixture. Fail without writing the fixture if the two outputs differ.
  • Get the fixture committed. .gitignore ignores logs/ directories, so the fixture's sandbox/firewall/logs/ files depend on the negation that Add golden coverage for routed model audit analysis #67253 adds under pkg/cli/testdata/model_routing_golden/. The tool should check that the new files aren't ignored, or tell the user to force-add them.

After capturing a case, the user runs the make target from step 1 to generate its expected files.

3. Maintenance skill

Add .github/skills/model-routing-goldens/SKILL.md for agents to follow. It should cover:

  • When to refresh: only when audit's routing or token-usage output changed on purpose.
  • How to refresh: run make update-model-routing-golden and review the diff. Only the fields the change intends to affect may differ, and the PR must explain each changed field.
  • How to add a case: use the capture command from step 2. Runs from a private sandbox must be captured by a maintainer or by the person who reported the issue, because an agent can't access them.
  • What to check before committing: the fixture layout matches the downloaded-run layout, redaction is complete (no prompt, message or tool content and no real org, repo or user names), credit fields are intact, and the logs files are tracked by git.

Also add the skill to the intent routing list in AGENTS.md.

4. pr-finisher step

Add a step to .github/skills/pr-finisher/SKILL.md. When TestModelRoutingGolden* fails because of an intended output change, run make update-model-routing-golden and summarize the golden diff in the PR description. When the change is unintended, fix the code and leave the goldens unchanged.

5. Fixture README

Add a short pkg/cli/testdata/model_routing_golden/README.md. It should describe each of the five cases and the routing scenario it covers, list each case's source run, and describe the refresh workflow. It should point to the make target, the capture command and the skill.

Acceptance criteria

  • make update-model-routing-golden regenerates all the goldens, and after a refresh with no code changes, git diff is empty.
  • The capture command recreates an existing case from its source run, and the analysis output matches that case's committed expected.json.
  • The capture command fails when the trimmed fixture's analysis output differs from the full download's output.
  • The skill, the pr-finisher step and the README are in place and reference each other.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions