Skip to content

feat: CLI reads session_id from AGENT_EVENT_BUS_SESSION_ID env var - #95

Merged
evansenter merged 2 commits into
mainfrom
feat/cli-session-id-env
Jan 27, 2026
Merged

feat: CLI reads session_id from AGENT_EVENT_BUS_SESSION_ID env var#95
evansenter merged 2 commits into
mainfrom
feat/cli-session-id-env

Conversation

@evansenter

@evansenter evansenter commented Jan 25, 2026

Copy link
Copy Markdown
Owner

Summary

When --session-id is not provided, the CLI now falls back to the AGENT_EVENT_BUS_SESSION_ID environment variable. This allows hooks that set this variable to have their CLI publishes properly attributed instead of showing from: anonymous.

Changes

  • cli.py: Add env var fallback for session_id in cmd_publish()
  • test_cli.py: Add 2 tests for env var behavior

Related Settings Updates

Also updated ~/.claude/settings.json (outside this repo):

  • Renamed EVENT_BUS_URLAGENT_EVENT_BUS_URL (correct name)
  • Added AGENT_SESSION_ANALYTICS_URL

Test plan

  • make check passes (263 tests)
  • New tests cover both env var fallback and explicit override

🤖 Generated with Claude Code

When --session-id is not provided, the CLI now falls back to the
AGENT_EVENT_BUS_SESSION_ID environment variable. This allows hooks
that set this variable to have their CLI publishes properly attributed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude

claude Bot commented Jan 25, 2026

Copy link
Copy Markdown

Prompt: evansenter/dotfiles/.../claude-review.md

Code Review

Summary

This PR adds environment variable fallback for --session-id in the CLI's publish command, allowing hooks that set AGENT_EVENT_BUS_SESSION_ID to have their publishes properly attributed instead of showing from: anonymous.

Issues Found

Critical

None

Important

None

Suggestions

  • CLAUDE.md Operations section - The new AGENT_EVENT_BUS_SESSION_ID environment variable should be documented alongside the other env vars (AGENT_EVENT_BUS_DB, AGENT_EVENT_BUS_ICON, AGENT_EVENT_BUS_AUTH_DISABLED). This maintains consistency with the project's documentation patterns and helps users discover the feature.

  • src/agent_event_bus/cli.py:346 - The --session-id argument help text could mention the env var fallback for discoverability (e.g., help="Your session ID (default: $AGENT_EVENT_BUS_SESSION_ID)"). Other CLI tools commonly document env var fallbacks in their help text. Currently, the --url argument at line 305 follows a similar pattern.

Verdict

REQUEST_CHANGES - Code is correct and well-tested, but the new environment variable should be documented in CLAUDE.md and CLI help for consistency with existing patterns.


Automated review by Claude Code

- Add env var to CLAUDE.md Operations section
- Update CLI --session-id help text to mention env var fallback

Addresses claude-review feedback.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@evansenter

Copy link
Copy Markdown
Owner Author

Feedback Addressed

Implemented

  • [Suggestion] CLAUDE.md - Added AGENT_EVENT_BUS_SESSION_ID to Operations section
  • [Suggestion] cli.py - Updated --session-id help text to mention env var fallback

@claude

claude Bot commented Jan 27, 2026

Copy link
Copy Markdown

Prompt: evansenter/dotfiles/.../claude-review.md

Code Review

Summary

This PR adds environment variable fallback for --session-id in the CLI's publish command, allowing hooks that set AGENT_EVENT_BUS_SESSION_ID to have their publishes properly attributed instead of showing from: anonymous.

Issues Found

Critical

None

Important

None

Suggestions

None

Previously Addressed (Filtered)

  • CLAUDE.md - Added AGENT_EVENT_BUS_SESSION_ID to Operations section (Implemented)
  • cli.py - Updated --session-id help text to mention env var fallback (Implemented)

2 items from prior feedback rounds were not re-raised.

Verdict

APPROVE - Both suggestions from the previous review have been implemented. The code correctly prioritizes explicit --session-id over env var, documentation is complete, and test coverage is thorough.


Automated review by Claude Code

@evansenter
evansenter merged commit 4337d2a into main Jan 27, 2026
5 checks passed
@evansenter
evansenter deleted the feat/cli-session-id-env branch January 27, 2026 06:50
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