Skip to content

fix(tui): Don't overwrite the agent that was specified on the command line#20554

Merged
rekram1-node merged 1 commit intoanomalyco:devfrom
CarloWood:CW05-honour-argument-agent
Apr 15, 2026
Merged

fix(tui): Don't overwrite the agent that was specified on the command line#20554
rekram1-node merged 1 commit intoanomalyco:devfrom
CarloWood:CW05-honour-argument-agent

Conversation

@CarloWood
Copy link
Copy Markdown
Contributor

If both -s and --agent are given, we should pick the agent from the latter.

Issue for this PR

Closes #20536

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

At this point the command line arguments are already known; so we can simply check
for the existence of args.agent (with const args = useArgs()) to know if an --agent
command line parameter exists. If it does then the agent found in the last user message
of the given session ID -- that previously was unconditionally used to overwrite whatever
was in local.agent -- is no longer used. We simply keep the agent value that was
specified on the command line.

How did you verify your code works?

I repeated the 'Steps to reproduce' steps of #20536.
I can now specify -s and --agent at the same time and pick any agent I want.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Hey! Your PR title Don't overwrite the agent that was specified on the command line doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

PR #18586: "fix(tui): prevent subagent sessions from overwriting the selected agent"

This PR appears to address a similar issue where agent selection was being unintentionally overwritten in certain scenarios (specifically for subagent sessions in the TUI). Your current PR (#20554) handles the same type of problem but specifically for the command-line interface when both -s (session) and --agent parameters are provided.

These are likely addressing different code paths but the same underlying concern about preserving intentional agent selection.

@CarloWood CarloWood changed the title Don't overwrite the agent that was specified on the command line fix: Don't overwrite the agent that was specified on the command line Apr 2, 2026
@CarloWood
Copy link
Copy Markdown
Contributor Author

PR #18586: "fix(tui): prevent subagent sessions from overwriting the selected agent"

* [fix(tui): prevent subagent sessions from overwriting the selected agent #18586](https://github.com/anomalyco/opencode/pull/18586)

This PR appears to address a similar issue where agent selection was being unintentionally overwritten in certain scenarios (specifically for subagent sessions in the TUI). Your current PR (#20554) handles the same type of problem but specifically for the command-line interface when both -s (session) and --agent parameters are provided.

These are likely addressing different code paths but the same underlying concern about preserving intentional agent selection.

I checked #18586 and it is unrelated (it deals with subagents, not the collision between -s and --agent), although also making changes close to where I made a changes, in the same file. What it is doing will not be influenced by this patch (or the other way around).

@CarloWood CarloWood changed the title fix: Don't overwrite the agent that was specified on the command line fix(tui): Don't overwrite the agent that was specified on the command line Apr 2, 2026
@CarloWood CarloWood force-pushed the CW05-honour-argument-agent branch from d1cfe84 to 6ec6bef Compare April 12, 2026 22:50
If both -s and --agent are given, we should pick the agent from the latter.

Closes anomalyco#20536
@CarloWood CarloWood force-pushed the CW05-honour-argument-agent branch from dbbe48d to ec56964 Compare April 15, 2026 23:27
@rekram1-node rekram1-node merged commit a554fad into anomalyco:dev Apr 15, 2026
8 checks passed
@CarloWood CarloWood deleted the CW05-honour-argument-agent branch April 16, 2026 12:26
jerome-benoit pushed a commit to jerome-benoit/opencode that referenced this pull request Apr 16, 2026
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.

--agent command line parameter ignored when used together with -s <session>.

2 participants