Skip to content

fix(cmd): add --user flag to agent chat for user_id authentication#714

Open
stanleykao72 wants to merge 1 commit intonextlevelbuilder:mainfrom
stanleykao72:fix/cli-chat-user-id
Open

fix(cmd): add --user flag to agent chat for user_id authentication#714
stanleykao72 wants to merge 1 commit intonextlevelbuilder:mainfrom
stanleykao72:fix/cli-chat-user-id

Conversation

@stanleykao72
Copy link
Copy Markdown

@stanleykao72 stanleykao72 commented Apr 6, 2026

Summary

  • goclaw agent chat never sends user_id in the WebSocket connect frame
  • Gateway requires user_id for chat.send, so the CLI always fails with user_id is required
  • All other clients (browser, Telegram, LINE, Discord, Slack) send user_id during connect — CLI is the only channel missing it

Changes

  • cmd/agent_chat.go: Add --user / -u flag
  • cmd/agent_chat_client.go: Pass user_id in connect params

Usage

# Before: always fails
goclaw agent chat --name my-agent -m "hello"
# Error: agent error: user_id is required

# After: works
goclaw agent chat --name my-agent --user stanley -m "hello"

Test plan

  • goclaw agent chat --name default --user testuser -m "hello" → agent responds (no user_id is required error) → verified
  • goclaw agent chat --name default -m "hello" (no --user) → still fails with user_id is required (backward compatible, no silent default) → verified
  • Interactive REPL mode with --user flag → works across multiple messages in same session → verified

🤖 Generated with Claude Code

The CLI agent chat command connects via WebSocket but never sends
user_id in the connect params. The gateway requires user_id for
chat.send, making the CLI unusable for any agent interaction.

All other clients (browser, Telegram, LINE, etc.) send user_id
during connect. The CLI was the only channel missing it.

Adds --user / -u flag that passes user_id in the connect frame.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@stanleykao72
Copy link
Copy Markdown
Author

Test Plan Verification

Tested on a staging build of fix/cli-chat-user-id HEAD 8f78f19f against a goclaw gateway running on localhost:18790.

Scenario 1: --user testuser success path

$ ./goclaw agent chat --name e-smith-hub --user testuser -m "ping from smoke test"
Connected to gateway at 127.0.0.1:18790
Hey! Pong 🏓

I just came online — fresh start, no memory yet. Who am I? Who are you?
$ echo $?
0

✅ Agent connected, responded; no user_id is required error.

Scenario 2: no --user flag — backward-compat fail

$ ./goclaw agent chat --name e-smith-hub -m "ping"
Connected to gateway at 127.0.0.1:18790
Error: agent error: user_id is required

✅ The expected error message surfaces (no silent default). Note: the CLI prints the error to stderr but exits 0 today — the backward-compat behavior (rejection of the request) is intact, but a follow-up could change the exit code to non-zero for clearer scripting use. Out of scope for this PR.

Scenario 3: Interactive REPL with --user across multiple messages

$ printf "first\nsecond\nthird\n" | ./goclaw agent chat --name e-smith-hub --user testuser
Connected to gateway at 127.0.0.1:18790

GoClaw Interactive Chat (agent: e-smith-hub, model: openai-codex/gpt-4.1)
Session: agent:e-smith-hub:cli:direct:local
Type "exit" to quit, "/new" for new session

You: <agent reply 1>
You: <agent reply 2>
You: <agent reply 3>

✅ REPL started, session ID stable across all 3 messages, each round-trip reached the agent without user_id is required. user_id propagates correctly across the session.

All 3 test-plan items now pass — ready for review.

🤖 Verified by Claude Code

stanleykao72 added a commit to stanleykao72/goclaw that referenced this pull request Apr 16, 2026
…staging verification evidence

Capture the live LINE staging session and the CLI smoke run carried out
on 2026-04-16 against the e-smith-borrowed channel and the staging goclaw
binary built from feat/line-channel-clean.

  - test-evidence/pr715-line-staging.md: 1:1 PASS (5+ events), image PASS
    (3 vision attaches), group STAGING CONSTRAINED by LINE OA Manager
    Chat-mode intercept (links to TestClassifySource_* unit tests for
    code-path coverage), multi-agent PASS by unit test
    (TestMultiChannelHookIsolation) with single-agent staging fallback.

  - test-evidence/pr714-cli-smoke.md: three CLI scenarios all PASS —
    --user success, no --user backward-compat fail, interactive REPL
    multi-message session persistence.

These files live in esmith/main only; PR nextlevelbuilder#715 itself does not include
this directory. PR body links to test-evidence URLs on the fork for
reviewers who want the full transcript.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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