Skip to content

chore: deduplicate agent flags#2672

Open
janburzinski wants to merge 24 commits into
mainfrom
emdash/arg-multiple-times-m4kpi
Open

chore: deduplicate agent flags#2672
janburzinski wants to merge 24 commits into
mainfrom
emdash/arg-multiple-times-m4kpi

Conversation

@janburzinski

Copy link
Copy Markdown
Collaborator

Description

  • deduplicates generated singleton approval/trust flags across providers
  • prevent user extra flags from causing deduplicated flag errors
Checklist
  • I kept this PR small and focused
  • I ran a self-review before opening this PR
  • I ran the relevant local checks or explained why not
  • I updated docs when behavior or setup changed
  • I added or updated tests when behavior changed, or explained why not
  • I only added comments where the logic is not obvious
  • I used Conventional Commits for commit
    messages and, when possible, the PR title

@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds deduplicateFlags arrays to 21 agent provider plugins and the buildStandardCommand helper, preventing "duplicate flag" errors when users supply auto-generated singleton flags (like --dangerously-skip-permissions or --yolo) in their own extraArgs. The implementation keeps the first occurrence of each listed flag and discards subsequent duplicates.

  • dedupeFlags in standard-command.ts uses exact-string Set matching; flags that appear in both the generated args (from autoApproveFlag, defaultArgs, or newConversationFlag) and user extraArgs are correctly deduplicated to one occurrence.
  • Both a unit-level test in standard-command.test.ts and a parameterised integration test in index.test.ts covering all 21 providers are added to confirm the behaviour.

Confidence Score: 5/5

Safe to merge — purely additive configuration with no changes to runtime logic outside the already-tested deduplication path.

The deduplication logic in standard-command.ts was unchanged; this PR only populates the existing deduplicateFlags field for 21 providers. Each provider's flag list matches the flags actually generated by that provider's spec, and the new parameterised test in index.test.ts exercises every provider end-to-end. No existing behaviour is altered for users who don't pass duplicate flags.

No files require special attention. All updated provider files follow the same straightforward pattern and are covered by the new tests.

Important Files Changed

Filename Overview
packages/core/src/agents/plugins/helpers/standard-command.ts Core dedupeFlags helper is correct — O(n) filter over args, Set-based exact matching, first-occurrence wins (generated flags precede user extraArgs in build order)
packages/core/src/agents/plugins/helpers/standard-command.test.ts New test confirms that a flag present in both autoApproveFlag and extraArgs is deduplicated to exactly one occurrence while non-singleton flags (--verbose) are preserved
packages/plugins/src/agents/impl/index.test.ts Parameterised test covering all 21 updated providers verifies each deduplicateFlags entry is applied correctly; all flag lists match the actual flags used in each provider's spec
packages/plugins/src/agents/impl/codex/index.ts Adds --dangerously-bypass-hook-trust to the existing deduplicateFlags list; matches the flag present in autoApproveFlag; pre-existing --dangerously-bypass-approvals-and-sandbox entry is a harmless defensive catch for a legacy flag
packages/plugins/src/agents/impl/gemini/index.ts Multi-word autoApproveFlag (--approval-mode=yolo --skip-trust) is correctly split before deduplication; both tokens listed in deduplicateFlags
packages/plugins/src/agents/impl/commandcode/index.ts Three flags (--trust, --skip-onboarding from defaultArgs, --yolo from autoApproveFlag) correctly listed in deduplicateFlags
packages/plugins/src/agents/impl/auggie/index.ts --allow-indexing is a defaultArgs entry (always generated), not an autoApproveFlag; deduplication against user extraArgs is still correct because defaultArgs are prepended before extraArgs
packages/plugins/src/agents/impl/letta/index.ts Both --yolo (autoApproveFlag) and --new (newConversationFlag) are included in deduplicateFlags; on resume sessions --new won't be generated so a user-supplied duplicate simply passes through once — correct behaviour

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[buildStandardCommand] --> B[Push defaultArgs]
    B --> C[Push session/resume flags]
    C --> D{ctx.autoApprove?}
    D -->|yes| E[Push autoApproveFlag tokens]
    D -->|no| F[Skip autoApproveFlag]
    E --> G[Push modelFlag]
    F --> G
    G --> H[Push ctx.extraArgs]
    H --> I{deduplicateFlags defined?}
    I -->|yes| J[dedupeFlags: keep first occurrence of each singleton flag]
    I -->|no| K[Use args as-is]
    J --> L[Return AgentCommand]
    K --> L

    style J fill:#d4edda,stroke:#28a745
    style H fill:#fff3cd,stroke:#ffc107
    style E fill:#cce5ff,stroke:#004085
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[buildStandardCommand] --> B[Push defaultArgs]
    B --> C[Push session/resume flags]
    C --> D{ctx.autoApprove?}
    D -->|yes| E[Push autoApproveFlag tokens]
    D -->|no| F[Skip autoApproveFlag]
    E --> G[Push modelFlag]
    F --> G
    G --> H[Push ctx.extraArgs]
    H --> I{deduplicateFlags defined?}
    I -->|yes| J[dedupeFlags: keep first occurrence of each singleton flag]
    I -->|no| K[Use args as-is]
    J --> L[Return AgentCommand]
    K --> L

    style J fill:#d4edda,stroke:#28a745
    style H fill:#fff3cd,stroke:#ffc107
    style E fill:#cce5ff,stroke:#004085
Loading

Reviews (1): Last reviewed commit: "test(codex): remove duplicate dedupe cas..." | Re-trigger Greptile

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.

1 participant