openclaw - ✅(Solved) Fix [Feature]: openclaw tui --agent to bind TUI session to a specific agent [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#51481Fetched 2026-04-08 01:10:41
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2commented ×1labeled ×1mentioned ×1

Add --agent flag to openclaw tui so TUI sessions can bind to a specific agent configuration and model, instead of always defaulting to the main agent.

Root Cause

Add --agent flag to openclaw tui so TUI sessions can bind to a specific agent configuration and model, instead of always defaulting to the main agent.

Fix Action

Fix / Workaround

No clean workaround exists. openclaw agent --agent <id> is one-shot and cannot maintain interactive ClawTeam inbox coordination. Manually switching the main agent's model before/after spawning is fragile and affects all running sessions.

PR fix notes

PR #6: feat: add --openclaw-agent flag to spawn command

Description (problem / solution / changelog)

Summary

Add --openclaw-agent <id> flag to clawteam spawn command, allowing users to specify which OpenClaw agent configuration (and thus which model) spawned workers should use.

Problem

When ClawTeam spawns multiple agents via openclaw tui, all workers inherit the default (main) agent's model configuration. If main uses an expensive model (e.g., Claude Opus), all workers run on Opus — even when cheaper models (Sonnet, Haiku) would suffice for their tasks.

There is currently no way to control which model spawned workers use.

Solution

# Before: all workers use main agent (Opus)
clawteam spawn -t my-team -n researcher --task "Do research"

# After: specify a different agent config (e.g., one using Sonnet)
clawteam spawn -t my-team -n researcher --task "Do research" --openclaw-agent researcher

The flag passes --agent <id> to openclaw tui when building the spawn command.

Changes

  • spawn/base.py: Add openclaw_agent parameter to SpawnBackend.spawn()
  • spawn/tmux_backend.py: Pass --agent to openclaw tui when openclaw_agent is set
  • spawn/subprocess_backend.py: Accept openclaw_agent parameter (signature compatibility)
  • cli/commands.py: Add --openclaw-agent CLI option

Note

This feature requires openclaw tui to support the --agent parameter, which has been requested upstream (openclaw/openclaw#51481). The ClawTeam side is ready once OpenClaw adds that support.

Testing

Verified that clawteam spawn --help shows the new --openclaw-agent option.

Changed files

  • clawteam/cli/commands.py (modified, +3/-1)
  • clawteam/spawn/base.py (modified, +1/-0)
  • clawteam/spawn/subprocess_backend.py (modified, +7/-0)
  • clawteam/spawn/tmux_backend.py (modified, +16/-0)
  • tests/test_openclaw_agent.py (added, +116/-0)

Code Example

# Current (always uses main agent)
openclaw tui --session my-session --message "Do research"

# Proposed (use a specific agent with its own model config)
openclaw tui --agent researcher --session my-session --message "Do research"
RAW_BUFFERClick to expand / collapse

Summary

Add --agent flag to openclaw tui so TUI sessions can bind to a specific agent configuration and model, instead of always defaulting to the main agent.

Problem to solve

When using multi-agent swarm tools like ClawTeam, each spawned agent runs openclaw tui in its own tmux window. All spawned TUI sessions default to the main agent, inheriting its model configuration.

If main uses an expensive model (e.g., Claude Opus), all ClawTeam workers run on Opus — even when cheaper models (Sonnet) would suffice for research/data-gathering tasks.

openclaw agent supports --agent but is one-shot (not interactive), so it cannot be used for ClawTeam's inbox-based coordination which requires persistent sessions.

Proposed solution

Add --agent <id> flag to openclaw tui:

# Current (always uses main agent)
openclaw tui --session my-session --message "Do research"

# Proposed (use a specific agent with its own model config)
openclaw tui --agent researcher --session my-session --message "Do research"

The TUI session would use the model and configuration defined for that agent in openclaw.json, rather than always defaulting to the main agent.

Alternatives considered

No clean workaround exists. openclaw agent --agent <id> is one-shot and cannot maintain interactive ClawTeam inbox coordination. Manually switching the main agent's model before/after spawning is fragile and affects all running sessions.

Impact

Affected: All users running multi-agent swarms via ClawTeam or similar tools Severity: Medium (cost inefficiency, no functional blocker) Frequency: Every ClawTeam spawn session Consequence: 5-10x higher token costs when workers use Opus instead of Sonnet for simple tasks

Evidence/examples

  • ClawTeam (https://github.com/HKUDS/ClawTeam) spawns openclaw tui for each worker agent
  • openclaw agent already supports --agent flag (one-shot mode)
  • A companion PR has been submitted to ClawTeam-OpenClaw fork adding --openclaw-agent to clawteam spawn, ready to pass --agent once supported by tui
  • OpenClaw 2026.3.13, ClawTeam 0.3.0, macOS

Additional information

Should be backward-compatible: omitting --agent keeps current behavior (defaults to main agent). The flag only affects model/config routing, not session isolation or workspace setup.

extent analysis

Fix Plan

To add the --agent flag to openclaw tui, follow these steps:

  • Update the openclaw tui command-line parser to accept the --agent flag.
  • Modify the TUI session initialization to use the specified agent's model and configuration when the --agent flag is provided.
  • Ensure backward compatibility by defaulting to the main agent when the --agent flag is omitted.

Example code changes:

import argparse

# ...

def parse_args():
    parser = argparse.ArgumentParser()
    # ...
    parser.add_argument('--agent', help='Specify the agent to use')
    # ...
    return parser.parse_args()

def initialize_tui_session(args):
    if args.agent:
        # Use the specified agent's model and configuration
        agent_config = load_agent_config(args.agent)
        # ...
    else:
        # Default to the main agent
        agent_config = load_main_agent_config()
        # ...

# ...

Verification

To verify the fix, run the following tests:

  • Launch openclaw tui with the --agent flag and a valid agent ID. Verify that the TUI session uses the specified agent's model and configuration.
  • Launch openclaw tui without the --agent flag. Verify that the TUI session defaults to the main agent.
  • Test with different agent IDs and verify that the correct models and configurations are used.

Example test commands:

openclaw tui --agent researcher --session my-session --message "Do research"
openclaw tui --session my-session --message "Do research"

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Feature]: openclaw tui --agent to bind TUI session to a specific agent [1 pull requests, 1 comments, 2 participants]