Skip to content

feat(evals): add reviewable eval drafts from session logs - #29019

Open
ved015 wants to merge 4 commits into
google-gemini:mainfrom
Gsoc26:feat/eval-from-log
Open

feat(evals): add reviewable eval drafts from session logs#29019
ved015 wants to merge 4 commits into
google-gemini:mainfrom
Gsoc26:feat/eval-from-log

Conversation

@ved015

@ved015 ved015 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

eval:from-log helps maintainers and contributors turn a real Gemini CLI interaction into the starting point for a behavioral evaluation.

Session logs are valuable because they capture realistic prompts, tool usage, and failure scenarios. However, a log only records what happened; it does not define what should have happened. This feature bridges that gap by extracting one original human turn, combining it with human-defined expectations and an explicitly selected workspace state, and producing a reviewable behavioral eval draft.

The entire workflow is local and deterministic. It does not call an LLM, make network requests, upload the session, infer expected behavior from the observed trajectory, or claim that the generated draft is already a finished regression eval.

Details

End-to-End Workflow

  1. Locate the source interaction. Start with a local Gemini CLI JSONL session (or a legacy JSON session) and the original workspace in which it ran.
  2. Inspect eligible turns. --list-turns presents the plain-text human turns that can safely form the basis of an eval, along with observed tool calls and possible fixture paths as review evidence.
  3. Select one human request. Choose the exact turn with --message-id. Internal tool responses, slash commands, multimodal turns, and persisted compression summaries are not treated as human prompts.
  4. Define the intended behavior. Explicitly state which registered tools should or should not be called with --expect-tool and --forbid-tool. Observed calls from the log never become assertions automatically.
  5. Define the starting workspace. Select only the regular files the eval actually needs with --fixture, or explicitly confirm that no fixtures are required. Files are copied from the matching original workspace, never reconstructed from logged tool output.
  6. Preview the draft. Preview is the default. The complete generated eval is displayed without modifying the repository.
  7. Write deliberately. After reviewing the preview, --write can create one new .eval.ts file directly under evals/. Existing files are never overwritten.
  8. Finish the behavioral eval. Refine the assertions, prove that the intended assertion fails before the behavior fix, remove the generated runtime guard, and then verify that the corrected behavior passes consistently.

Architecture

flowchart TD
  subgraph Inputs
    session["Local Gemini CLI session<br/>JSONL or legacy JSON"]
    workspace["Original workspace<br/>explicit fixture choices"]
    intent["Human intent<br/>expected and forbidden tools"]
  end

  session --> loader["Safe session loader<br/>stable snapshot, size, UTF-8, and format checks"]
  loader --> turns["Turn analyzer<br/>plain-text human turns"]
  turns --> selected["Contributor selects one turn"]
  turns -.-> evidence["Observed tool calls and candidate paths<br/>displayed as evidence, never expectations"]

  workspace --> fixtures["Workspace and fixture safety gates<br/>project match, containment, portability, and secret checks"]
  intent --> expectations["Registered tool expectations<br/>canonicalized and conflict-checked"]

  selected --> generator["Deterministic eval draft generator"]
  fixtures --> generator
  expectations --> generator

  generator --> validator["Existing eval analyzer and validator"]
  validator --> mode{"Output mode"}
  mode -->|default| preview["Preview only<br/>nothing written"]
  mode -->|explicit write| file["New evals/*.eval.ts draft<br/>--write required, no overwrite"]

  evidence -.-> review["Human review<br/>stronger assertions and fail-before-fix proof"]
  preview --> review
  file --> review
  review --> ready["Remove runtime guard<br/>validated behavioral eval"]
Loading

What the Draft Contains

The generated file is a normal behavioral eval built around evalTest and includes:

  • A USUALLY_PASSES policy for the draft stage
  • The selected human prompt with machine-specific paths redacted where possible
  • Only the explicitly approved starting files
  • Initial assertions for the contributor-specified expected and forbidden tools
  • Review guidance and an unconditional runtime guard that keeps the draft fail-closed

The source is passed through the existing eval analyzer and validator before it is previewed or written. “Structural validation passed” means the file matches the repository's eval structure and registered tool contracts; it does not mean the behavior itself has passed.

Safety and Trust Model

The session log is treated as untrusted input throughout the workflow.

  • Session data is read from a stable local snapshot and rejected when it is malformed, non-UTF-8, or larger than the configured limit.
  • Log-observed tool names and tool results are never converted into executable assertions or workspace files.
  • All generated TypeScript values are serialized as data, including prompts, tool names, fixture paths, and fixture contents.
  • Fixture selection is explicit and tied to the original workspace's project identity.
  • Traversal, symlink escapes, non-portable paths, binary files, oversized files, common credential files, and detected secrets are rejected.
  • Output is restricted to a new, visible, direct child of evals/; preview remains the default and writes require --write plus an explicit path.
  • Human-readable terminal output escapes control and bidirectional display characters.
  • The runtime guard prevents an unreviewed draft from being mistaken for a completed eval.

Secret detection and path redaction are intentionally described as best effort. Contributors must still inspect the complete preview and create a small synthetic reproduction when the original prompt or required files contain sensitive information.

Scope and Limitations

This feature automates the mechanical and safety-sensitive parts of moving from a session to an eval draft. It deliberately does not:

  • Decide the correct expected behavior
  • Judge the quality of the model's final prose response
  • Recover an exact historical workspace from partial or post-mutation tool output
  • Support multimodal requests or synthetic conversation-compression summaries as prompts
  • Accept runtime-only MCP or extension tools that are not represented in the eval tool registry
  • Run the generated eval, contact a model, or prove that a regression exists

Those decisions remain with the contributor and reviewer because they require product intent, issue context, and fail-before-fix evidence that cannot be inferred reliably from a log alone.

Related Issues

Related to #28696

How to Validate

Inspect the command and locate an eligible human turn:

npm run eval:from-log -- --help

npm run eval:from-log -- \
  --log /path/to/session.jsonl \
  --workspace /path/to/original/workspace \
  --list-turns

Preview a draft without changing the repository:

npm run eval:from-log -- \
  --log /path/to/session.jsonl \
  --workspace /path/to/original/workspace \
  --message-id "paste-message-id-here" \
  --name "uses the expected file-reading tool" \
  --expect-tool read_file \
  --fixture package.json

Confirm that the output identifies the selected turn, keeps observed calls as evidence only, copies the fixture from the selected workspace, reports structural validation, prints the runtime guard, and writes nothing.

Then add --output evals/from-log-review.eval.ts --write. Confirm that exactly one new draft is written and that repeating the same command refuses to overwrite it.

Run the production-script typecheck and repository checks:

./node_modules/.bin/tsc --noEmit --pretty false --strict --skipLibCheck \
  --esModuleInterop --allowSyntheticDefaultImports --verbatimModuleSyntax \
  --module NodeNext --moduleResolution NodeNext --target ES2022 --types node \
  scripts/eval-from-log-cli.ts scripts/utils/session-turns.ts \
  scripts/utils/log-sanitizer.ts scripts/utils/eval-skeleton-generator.ts \
  scripts/utils/eval-from-log.ts
npm run test:scripts
npm run typecheck
npm run build
npm run lint:ci

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@ved015
ved015 requested review from a team as code owners August 24, 2026 14:44
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a powerful new workflow for improving agent reliability by enabling the direct conversion of behavioral bug reports into regression evaluations. By leveraging existing session logs, the new eval:from-log pipeline automates the creation of eval skeletons, including workspace reconstruction and data sanitization. This change streamlines the process of capturing and testing against specific agent failures, making it easier for contributors to submit high-quality regression tests.

Highlights

  • New eval:from-log pipeline: Introduced a new CLI command eval:from-log that automatically generates regression eval skeletons from Gemini CLI session logs, significantly reducing manual boilerplate.
  • Automated Workspace Reconstruction: Added utilities to parse session JSONL files, reconstruct the pre-session workspace state, and sanitize sensitive information (secrets, absolute paths) before generating eval files.
  • New Bug Report Template: Added a .github/ISSUE_TEMPLATE/bug_eval_report.yml to encourage users to provide session logs, which can now be directly converted into regression tests.
  • Documentation and Testing: Updated evals/README.md with a guide on generating evals from bug reports and added comprehensive integration tests for the new log-to-eval pipeline.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the size/xl An extra large PR label Aug 24, 2026
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

📊 PR Size: size/XL

  • Lines changed: 2858
  • Additions: +2858
  • Deletions: -0
  • Files changed: 12

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

🛑 Action Required: Evaluation Approval

Steering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged.

Maintainers:

  1. Go to the Workflow Run Summary.
  2. Click the yellow 'Review deployments' button.
  3. Select the 'eval-gate' environment and click 'Approve'.

Once approved, the evaluation results will be posted here automatically.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces the eval:from-log command and associated utility scripts to automatically generate sanitized and validated regression eval skeletons from Gemini CLI session logs. The review feedback identifies critical security vulnerabilities, including a potential Remote Code Execution (RCE) via code injection from unvalidated tool names in generateAssertBody, and a path traversal vulnerability in sanitizeFileMap where relative paths bypass absolute path checks. Additionally, the reviewer recommends hardening the manual CLI argument parser to prevent flags from incorrectly consuming subsequent flags as values when arguments are missing.

Comment thread scripts/utils/eval-skeleton-generator.ts Outdated
Comment thread scripts/utils/log-sanitizer.ts Outdated
Comment thread scripts/eval-from-log-cli.ts
@gemini-cli gemini-cli Bot added priority/p3 Backlog - a good idea but not currently a priority. area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Aug 24, 2026
@ved015
ved015 requested a review from a team as a code owner August 24, 2026 15:55
@ved015 ved015 changed the title feat(evals): add eval:from-log pipeline for generating regression evals feat(evals): add reviewable eval drafts from session logs Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p3 Backlog - a good idea but not currently a priority. size/xl An extra large PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant