Skip to content

btw spawn with invalid bearer token triggers gateway/session disconnect #72574

@dodge1218

Description

@dodge1218

Summary

Running btw spawn codex 5.5 with an invalid or expired bearer token returns a 401 (expected), but also appears to destabilize the active OpenClaw gateway session, leading to a disconnect (gateway disconnected: closed | idle). This requires a manual openclaw gateway restart to recover.

Expected Behavior

  • btw command fails gracefully with authentication error
  • Active agent session and gateway remain stable
  • No disconnect or need for restart

Actual Behavior

  • btw returns:

    401 authentication_error: Invalid bearer token
    
  • Immediately followed by:

    gateway disconnected: closed | idle
    
  • Session becomes unusable until:

    openclaw gateway restart
    

Environment

  • OpenClaw version: 2026.4.9
  • OS: Linux Mint (Ubuntu/Debian-based)
  • Hardware: ThinkPad X1 Carbon
  • Active agent: github-copilot/claude-opus-4.7
  • Running via terminal (local install, systemd service)

Steps to Reproduce

  1. Start OpenClaw normally (openclaw or agent session active)

  2. Ensure bearer token for btw/Codex route is invalid or expired

  3. Run:

    btw spawn codex 5.5
    
  4. Observe:

    • 401 error
    • gateway disconnect

Logs

btw failed: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"}}

gateway disconnected: closed | idle

Impact

  • Breaks active session unexpectedly
  • Requires manual gateway restart
  • Makes btw unsafe to test/debug in live sessions
  • Poor failure isolation between auxiliary agent spawning and core gateway

Hypothesis

btw spawn may be:

  • Sharing or mutating the same gateway client/session
  • Not isolating failed auth paths
  • Triggering a teardown on error instead of failing locally

Suggested Fix

  • Isolate btw spawn calls from main gateway session
  • Ensure auth failures do not propagate to gateway lifecycle
  • Add retry-safe or sandboxed execution for helper agents

Additional Notes

This feels like a boundary violation between auxiliary agent execution (btw) and core session stability. Even with invalid credentials, the main agent should remain unaffected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions