Skip to content

Explain summary provider#887

Draft
peyton-alt wants to merge 4 commits intocodex-explain-generatefrom
explain-summary-provider
Draft

Explain summary provider#887
peyton-alt wants to merge 4 commits intocodex-explain-generatefrom
explain-summary-provider

Conversation

@peyton-alt
Copy link
Copy Markdown
Contributor

@peyton-alt peyton-alt commented Apr 9, 2026

Summary

This stacks on top of #875 and adds summary provider selection for entire explain --generate.

When a summary provider is already configured, explain --generate uses it. If none is configured, the command resolves one at first use:

  • if exactly one enabled summary-capable agent exists, it is selected and persisted
  • if multiple enabled summary-capable agents exist, the user is prompted once and the choice is persisted
  • if none are available, the command falls back to Claude

This PR also adds entire configure --summarize-provider and --summarize-model, plus shared CLI execution cleanup for provider transports.

Changes

  • add summary_generation settings for persisted provider/model preference
  • add first-use provider resolution and persistence in explain --generate
  • print provider and model after successful generation
  • add configure flags for updating summary provider and model
  • validate provider selection and clear stale models when switching providers
  • add text-generation support for Codex, Gemini, Cursor, and Copilot via the shared summarize prompt
  • centralize isolated CLI execution in a shared helper and reuse it in summarization

Testing

  • mise run fmt
  • mise run test
  • mise run lint

Notes

Copilot AI review requested due to automatic review settings April 9, 2026 03:32
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c3d84bc. Configure here.


// GenerateText sends a prompt to the Copilot CLI and returns the raw text response.
func (c *CopilotCLIAgent) GenerateText(ctx context.Context, prompt string, model string) (string, error) {
args := []string{"-p", prompt, "--allow-all-tools"}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot and Cursor pass large prompts as CLI arguments

Medium Severity

The Copilot and Cursor GenerateText implementations embed the full prompt as a command-line argument via -p. When used through TextGeneratorAdapter for summarization, this prompt includes the entire formatted transcript, which can be very large. This can exceed OS argument length limits (e.g., ~256 KB on macOS), causing the exec call to fail. Other providers (Claude Code, Codex, Gemini) correctly pass the prompt via stdin.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c3d84bc. Configure here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a configurable “summary provider” pipeline for entire explain --generate, allowing users to choose (and persist) which agent/provider + model to use for on-demand checkpoint summary generation, while reusing the shared summarization prompt and JSON parsing.

Changes:

  • Introduces a TextGeneratorAdapter to generate summaries via any agent.TextGenerator using the shared summarization prompt + parser.
  • Adds summary-provider resolution + persistence for explain --generate, including interactive selection when multiple providers are available.
  • Extends settings/configure flow with summary_generation settings and new entire configure flags (--summarize-provider, --summarize-model), plus shared CLI isolation helpers for provider CLIs.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cmd/entire/cli/summarize/text_generator.go Adds adapter to use any agent.TextGenerator for summary generation with shared prompt/parsing.
cmd/entire/cli/summarize/text_generator_test.go Tests adapter passes model + includes condensed transcript in prompt.
cmd/entire/cli/summarize/claude.go Refactors Claude generator to use shared isolated CLI runner and shared summary parsing.
cmd/entire/cli/summarize/claude_test.go Updates env-stripping test to use shared agent.StripGitEnv.
cmd/entire/cli/setup.go Adds configure flags + settings update path for summary provider/model.
cmd/entire/cli/setup_test.go Adds tests verifying settings updates, validation, and non-leakage for new summary settings.
cmd/entire/cli/settings/settings.go Adds summary_generation settings struct + merge logic.
cmd/entire/cli/settings/settings_test.go Adds coverage for loading/merging summary_generation.
cmd/entire/cli/explain.go Wires explain --generate to resolve and use the selected summary provider + prints provider/model details.
cmd/entire/cli/explain_summary_provider.go Implements provider discovery, interactive selection, persistence, and formatting of provider details.
cmd/entire/cli/explain_summary_provider_test.go Tests provider resolution from config, persistence when single provider is available, and formatting output.
cmd/entire/cli/agent/text_generator_cli.go Introduces shared isolated CLI runner and exported StripGitEnv.
cmd/entire/cli/agent/geminicli/generate.go Adds Gemini CLI text generation implementation via isolated runner.
cmd/entire/cli/agent/cursor/generate.go Adds Cursor agent CLI text generation implementation via isolated runner.
cmd/entire/cli/agent/copilotcli/generate.go Adds Copilot CLI text generation implementation via isolated runner.
cmd/entire/cli/agent/codex/generate.go Adds Codex CLI text generation implementation via isolated runner.
cmd/entire/cli/agent/claudecode/generate.go Refactors Claude Code agent text generation to use shared isolated runner.

Comment on lines +14 to +21
func (g *GeminiCLIAgent) GenerateText(ctx context.Context, prompt string, model string) (string, error) {
args := []string{"-p", ""}
if model != "" {
args = append(args, "--model", model)
}

result, err := agent.RunIsolatedTextGeneratorCLI(ctx, geminiCommandRunner, "gemini", "gemini", args, prompt)
if err != nil {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

Gemini CLI prompt is currently passed via stdin while the args use -p "". In this repo’s E2E harness, Gemini expects the prompt to be provided as the -p <prompt> argument (and typically includes -y plus ACCESSIBLE=1 to avoid interactive/TUI flows). As written, this is likely to generate an empty prompt or hang on interactivity. Update the invocation to pass prompt in the args (and add the non-interactive flags/env needed for reliable headless execution).

Copilot uses AI. Check for mistakes.
Comment on lines +84 to +89
func listEnabledSummaryProviders() ([]checkpointSummaryProvider, error) {
installed := listInstalledAgents(context.Background())
providers := make([]checkpointSummaryProvider, 0, len(installed))
for _, name := range installed {
ag, err := getSummaryAgent(name)
if err != nil {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

listEnabledSummaryProviders ignores the caller’s context by calling listInstalledAgents(context.Background()). This drops cancellation/deadline propagation and makes tests/behavior harder to control. Thread ctx through (e.g., accept ctx as a parameter and call listInstalledAgents(ctx)) so hook-install checks and agent loading respect the command context.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants