Skip to content

feat(agent-wiki): add compare-outcomes pass for contrastive guidelines#274

Open
vinodmut wants to merge 4 commits into
AgentToolkit:mainfrom
vinodmut:explorations/agent-wiki-compare-outcomes
Open

feat(agent-wiki): add compare-outcomes pass for contrastive guidelines#274
vinodmut wants to merge 4 commits into
AgentToolkit:mainfrom
vinodmut:explorations/agent-wiki-compare-outcomes

Conversation

@vinodmut

@vinodmut vinodmut commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What this adds

A new pass in the agent-wiki ingest pipeline — agent-wiki-compare-outcomes — that derives contrastive guidelines by comparing successful vs failed trajectories for the same (or similar) task, rather than mining rules from a single trajectory.

Every other pass in the pipeline (summarize / extract / synthesize) learns from one trajectory at a time. This pass learns from the contrast: a rule is only promoted when it's backed by a failed path, a successful path, and concrete trajectory evidence (task wording, observed tool/API calls, transcript/doc snippets). It can LLM-judge success/failure straight from the normalized transcript, so it does not depend on benchmark-specific outcome labels.

Extends the agent-wiki exploration merged in #268; related to the offline extraction/consolidation idea in #256.

Changes

explorations/agent-wiki/skills/
├── agent-wiki-compare-outcomes/
│   ├── SKILL.md                    new — the contrastive-comparison pass
│   └── scripts/compare_outcomes.py new — self-contained (stdlib only) evidence-pack builder
└── agent-wiki-ingest/SKILL.md      wired in as a conditional Step 4.5
  • The skill (SKILL.md): a 3-step workflow — build an evidence pack over normalized trajectories (grouped by task_id, success/failure judged or stored), inspect candidate rules, and promote only strong ones (one failed + one successful run in the same group, a task-action tool/API or workflow difference, source IDs for both sides). Weak candidates stay hypotheses, not rules.
  • The script (compare_outcomes.py): groups traces, contrasts success/failed runs, extracts tool/API calls + transcript evidence, optionally LLM-judges outcomes (--judge-outcomes never|missing|always), and emits an analysis JSON + Markdown (and optional render-ready guideline entities). Stdlib-only, no repo-internal deps.
  • Ingest wiring: added as Step 4.5 (conditional) — runs after synthesize, before consolidate — so contrastive guidelines can participate in clustering. Updated the description, the subagent list, the pipeline diagram, and added the step section. Skips cleanly when the corpus has no success/failure contrast.

Scope

This ports only the compare-outcomes capability + its ingest wiring from the appworld-agent-wiki-experiment branch. That branch also bundled unrelated changes (a consolidate "mine step" rewrite, a synthesize faithfulness rule, a run_agent_wiki_skill_pass.py helper) — those are intentionally not included here, to keep this PR focused.

Verification

  • ruff check + ruff format --check: clean.
  • mypy .: clean (the script carries the # mypy: ignore-errors header used by every sibling exploration/reference script).
  • detect-secrets: passes.
  • Smoke test: ran the script end-to-end on a success/failure trajectory pair — it groups by task_id, contrasts the two runs, and emits the analysis without error.

No changes outside explorations/agent-wiki/.

Summary by CodeRabbit

  • New Features

    • Added an optional compare-outcomes stage (Step 4.5) to the agent wiki ingest pipeline to generate evidence-backed contrastive guidelines by comparing successful vs. failed trajectories.
  • Documentation

    • Published the agent-wiki-compare-outcomes skill guide with run instructions, confidence/judging modes, and safety guardrails.
    • Updated design and ingest workflow documentation to reflect the new conditional, evidence-first stage and its placement before consolidation.

Adds a new pipeline skill, agent-wiki-compare-outcomes, that derives
*contrastive* guidelines by comparing successful vs failed trajectories for
the same/similar task — rather than mining rules from a single trajectory.
It LLM-judges success/failure from the normalized transcript (no dependency
on benchmark-specific outcome labels) and grounds each rule in evidence
(task wording, observed tool/API calls, transcript/doc snippets). The bundled
compare_outcomes.py is self-contained (stdlib only).

Wires it into the ingest orchestrator as a conditional Step 4.5 (after
synthesize, before consolidate): the description, subagent list, pipeline
diagram, and a new step section that spawns one agent-wiki-compare-outcomes
subagent over the corpus when there's a success/failure contrast, renders
any strong contrastive guidelines, and skips cleanly when there's no contrast.

Documents the new pass in the overview docs so it's discoverable: the README
skills tree, and design.md's pipeline diagram, stage table, ingest narrative,
and a short "learning from contrast" rationale.

Ported from the appworld-agent-wiki-experiment branch; scoped to just the new
skill + its ingest wiring (the branch's separate consolidate "mine step" and
synthesize changes are intentionally not included). Builder/CI conventions
followed: file-local `# mypy: ignore-errors` header matching sibling scripts.
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 85a94e8d-a04c-441a-8149-e44fcd27bbc6

📥 Commits

Reviewing files that changed from the base of the PR and between b9c8d44 and fa79c86.

📒 Files selected for processing (1)
  • explorations/agent-wiki/skills/agent-wiki-compare-outcomes/scripts/compare_outcomes.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • explorations/agent-wiki/skills/agent-wiki-compare-outcomes/scripts/compare_outcomes.py

📝 Walkthrough

Walkthrough

Adds an agent-wiki-compare-outcomes skill, updates agent-wiki docs and ingest orchestration to place it as a conditional step, and introduces a Python script that compares successful and failed traces to derive and render contrastive guidelines.

Changes

Compare-outcomes skill and pipeline docs

Layer / File(s) Summary
Design docs and skill spec
explorations/agent-wiki/README.md, explorations/agent-wiki/docs/design.md, explorations/agent-wiki/skills/agent-wiki-compare-outcomes/SKILL.md
Adds the compare-outcomes stage to the agent-wiki layout, pipeline diagram, stage table, ingest flow description, and new skill spec with workflow steps and guardrails.
Ingest orchestration update
explorations/agent-wiki/skills/agent-wiki-ingest/SKILL.md
Adds compare-outcomes to the orchestrated sub-skill sequence, inserts step 4.5, and documents its conditional execution and ordering before consolidation.

Compare-outcomes script

Layer / File(s) Summary
Trace ingestion and judging
explorations/agent-wiki/skills/agent-wiki-compare-outcomes/scripts/compare_outcomes.py
Adds CLI orchestration, trace summarization, evidence extraction, and optional LLM-based outcome judging with cache persistence.
Comparison and candidate derivation
explorations/agent-wiki/skills/agent-wiki-compare-outcomes/scripts/compare_outcomes.py
Groups traces by task, compares success/failure sets, derives contrastive candidates, and computes intensity-based rules with NLP and scoring helpers.
Output rendering and guideline payload
explorations/agent-wiki/skills/agent-wiki-compare-outcomes/scripts/compare_outcomes.py
Serializes trace data, renders Markdown, builds guideline payloads, formats guideline text, and exposes the module entry point.

Estimated code review effort: 4 (Complex) | ~60 minutes

Suggested reviewers: visahak

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the new agent-wiki compare-outcomes pass and its contrastive-guideline purpose.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@explorations/agent-wiki/skills/agent-wiki-compare-outcomes/scripts/compare_outcomes.py`:
- Around line 261-276: The client.chat.completions.create() call lacks an
explicit timeout configuration, which could cause the script to block
indefinitely if the API becomes unresponsive during batch processing. Add a
timeout to prevent excessive blocking: either add a timeout parameter when
instantiating the OpenAI client (e.g., timeout=60.0), or use the with_options()
method on the client immediately before calling chat.completions.create() to
apply the timeout at the request level. Choose whichever approach fits your
codebase structure best.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d9b9045a-28f8-42e2-8491-cb9edc3918d0

📥 Commits

Reviewing files that changed from the base of the PR and between 4d5b285 and b9c8d44.

📒 Files selected for processing (5)
  • explorations/agent-wiki/README.md
  • explorations/agent-wiki/docs/design.md
  • explorations/agent-wiki/skills/agent-wiki-compare-outcomes/SKILL.md
  • explorations/agent-wiki/skills/agent-wiki-compare-outcomes/scripts/compare_outcomes.py
  • explorations/agent-wiki/skills/agent-wiki-ingest/SKILL.md

Addresses CodeRabbit review finding: Add a timeout to the LLM API call

A 60s client-level timeout prevents the batch judge loop from blocking
indefinitely if the API becomes unresponsive.
@vinodmut

vinodmut commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@visahak @illeatmyhat @jayaramkr this is green and ready for review 🟢

All checks pass (GitHub Actions, CodeRabbit, and Tekton), and the branch is up to date with main. This ports just the compare-outcomes pass + its ingest wiring from the appworld experiment branch — no changes outside explorations/agent-wiki/. Would appreciate a look when you get a chance.

@visahak

visahak commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

@vinodmut This is part of the explorations, so it does not conflict with the full and lite usage paths right?

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

explorations don't hurt anything

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.

3 participants