Skip to content

feat: add Redis configuration and startup for agents#13

Merged
zbigniewsobiecki merged 1 commit intodevfrom
feature/add-redis-configuration
Jan 2, 2026
Merged

feat: add Redis configuration and startup for agents#13
zbigniewsobiecki merged 1 commit intodevfrom
feature/add-redis-configuration

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

Add Redis support alongside PostgreSQL, enabling agents to use in-memory data storage for caching, queues, and session management.

Changes

  • ✅ Install redis-server and redis-tools in Docker image
  • ✅ Configure Redis with AOF persistence, 256MB memory limit, and LRU eviction
  • ✅ Add startRedis() function following the same pattern as startPostgres()
  • ✅ Integrate Redis startup into agent lifecycle (base.ts, review.ts)
  • ✅ Document Redis CLI commands and usage in agent prompts
  • ✅ Both PostgreSQL and Redis are critical: agents fail if either service doesn't start

Redis Configuration

Parameter Value Description
Port 6379 Redis standard port
Bind 127.0.0.1 Localhost only for security
Persistence AOF (everysec) Append-only file with fsync every second
Memory Limit 256MB Maximum memory usage
Eviction Policy allkeys-lru LRU eviction when memory full
Protected Mode Disabled Easier local development
Access redis-cli Via Tmux gadget

Testing

  • ✅ All unit tests pass (62 tests across 7 files)
  • ✅ TypeScript compilation passes
  • ✅ Linting passes (no new warnings)
  • ✅ Pre-commit and pre-push hooks pass

Implementation Details

Files Modified

  1. Dockerfile - Redis installation and configuration
  2. src/agents/utils/setup.ts - startRedis() singleton function
  3. src/agents/utils/index.ts - Export startRedis
  4. src/agents/base.ts - Import and call startRedis() in setupRepository()
  5. src/agents/review.ts - Import and call startRedis() in setupRepository()
  6. src/agents/prompts/templates/partials/environment.eta - Redis documentation for agents

Agent Usage

Agents can now use Redis for:

  • Caching expensive computations
  • Queue management for background tasks
  • Session storage
  • Rate limiting
  • Temporary data storage

Example commands available to agents via Tmux gadget:

redis-cli ping                    # Check if Redis is running
redis-cli SET mykey "value"       # Store data
redis-cli GET mykey               # Retrieve data
redis-cli KEYS "*"                # List all keys
redis-cli INFO                    # Get server stats

Next Steps

After this PR is merged and deployed:

  1. Rebuild Docker image to include Redis
  2. Redis will start automatically when agents execute
  3. Agents can immediately start using Redis via CLI commands

Add Redis support alongside PostgreSQL, enabling agents to use in-memory
data storage for caching, queues, and session management.

Changes:
- Install redis-server and redis-tools in Docker image
- Configure Redis with AOF persistence, 256MB memory limit, and LRU eviction
- Add startRedis() function following the same pattern as startPostgres()
- Integrate Redis startup into agent lifecycle (base.ts, review.ts)
- Document Redis CLI commands and usage in agent prompts
- Both PostgreSQL and Redis are critical: agents fail if either service doesn't start

Redis configuration:
- Port: 6379 (standard)
- Bind: localhost only for security
- Persistence: AOF with everysec fsync
- Memory: 256MB with allkeys-lru eviction policy
- Access: via redis-cli through Tmux gadget

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit 1124fcb into dev Jan 2, 2026
2 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the feature/add-redis-configuration branch January 2, 2026 13:34
zbigniewsobiecki added a commit that referenced this pull request Jan 2, 2026
* feat: add Redis configuration and startup for agents (#13)

Add Redis support alongside PostgreSQL, enabling agents to use in-memory
data storage for caching, queues, and session management.

Changes:
- Install redis-server and redis-tools in Docker image
- Configure Redis with AOF persistence, 256MB memory limit, and LRU eviction
- Add startRedis() function following the same pattern as startPostgres()
- Integrate Redis startup into agent lifecycle (base.ts, review.ts)
- Document Redis CLI commands and usage in agent prompts
- Both PostgreSQL and Redis are critical: agents fail if either service doesn't start

Redis configuration:
- Port: 6379 (standard)
- Bind: localhost only for security
- Persistence: AOF with everysec fsync
- Memory: 256MB with allkeys-lru eviction policy
- Access: via redis-cli through Tmux gadget

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: increase post-job grace period to allow debug agent webhooks

The debug agent wasn't triggering because CASCADE was shutting down too
quickly after uploading session logs. Trello webhooks for attachment uploads
take a few seconds to arrive, but we were only waiting 5 seconds before
shutting down the machine.

Increased postJobGracePeriodMs from 5s to 45s to ensure:
1. Agent uploads session log attachment
2. Trello webhook is delivered while machine is still running
3. Debug agent trigger processes the webhook
4. Debug agent runs before shutdown

This fixes the race condition where attachment webhooks arrived after
the machine had already shut down.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* feat: add support for GitHub PR review submission webhooks

Both pull_request_review (review submission) and pull_request_review_comment
(review comments) now trigger the review agent for PRs with Trello card URLs.

Changes:
- Updated webhook queue to store event types alongside payloads
- Added PRReviewSubmittedTrigger for review submissions (approve/request changes)
- Fixed hardcoded event type in GitHub webhook dequeuing
- Both review types now trigger the review agent when PR has Trello card URL

Previously, only review comments triggered the agent. Now review submissions
(when someone clicks 'Approve' or 'Request Changes') also trigger it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: move cards to IN REVIEW after PR creation from GitHub webhooks

Adds automatic card movement logic to executeGitHubAgent that mirrors
the existing behavior in Trello webhook handler. When implementation
agent creates a PR, the card is now moved to the IN REVIEW list and
a comment with the PR URL is added.

This ensures consistent behavior regardless of whether the agent was
triggered by a Trello webhook or a GitHub webhook.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* docs: add GitHub webhook integration documentation

Adds comprehensive documentation for GitHub webhook setup:
- GitHub webhook endpoint in API endpoints section
- Detailed setup instructions with configuration steps
- List of supported GitHub triggers and their behavior
- Updated features list to include GitHub integration

This complements the recent GitHub webhook improvements including
PR review submission support and automatic card movement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
zbigniewsobiecki added a commit that referenced this pull request Jan 2, 2026
* feat: add Redis configuration and startup for agents (#13)

Add Redis support alongside PostgreSQL, enabling agents to use in-memory
data storage for caching, queues, and session management.

Changes:
- Install redis-server and redis-tools in Docker image
- Configure Redis with AOF persistence, 256MB memory limit, and LRU eviction
- Add startRedis() function following the same pattern as startPostgres()
- Integrate Redis startup into agent lifecycle (base.ts, review.ts)
- Document Redis CLI commands and usage in agent prompts
- Both PostgreSQL and Redis are critical: agents fail if either service doesn't start

Redis configuration:
- Port: 6379 (standard)
- Bind: localhost only for security
- Persistence: AOF with everysec fsync
- Memory: 256MB with allkeys-lru eviction policy
- Access: via redis-cli through Tmux gadget

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: increase post-job grace period to allow debug agent webhooks

The debug agent wasn't triggering because CASCADE was shutting down too
quickly after uploading session logs. Trello webhooks for attachment uploads
take a few seconds to arrive, but we were only waiting 5 seconds before
shutting down the machine.

Increased postJobGracePeriodMs from 5s to 45s to ensure:
1. Agent uploads session log attachment
2. Trello webhook is delivered while machine is still running
3. Debug agent trigger processes the webhook
4. Debug agent runs before shutdown

This fixes the race condition where attachment webhooks arrived after
the machine had already shut down.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* feat: add support for GitHub PR review submission webhooks

Both pull_request_review (review submission) and pull_request_review_comment
(review comments) now trigger the review agent for PRs with Trello card URLs.

Changes:
- Updated webhook queue to store event types alongside payloads
- Added PRReviewSubmittedTrigger for review submissions (approve/request changes)
- Fixed hardcoded event type in GitHub webhook dequeuing
- Both review types now trigger the review agent when PR has Trello card URL

Previously, only review comments triggered the agent. Now review submissions
(when someone clicks 'Approve' or 'Request Changes') also trigger it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: move cards to IN REVIEW after PR creation from GitHub webhooks

Adds automatic card movement logic to executeGitHubAgent that mirrors
the existing behavior in Trello webhook handler. When implementation
agent creates a PR, the card is now moved to the IN REVIEW list and
a comment with the PR URL is added.

This ensures consistent behavior regardless of whether the agent was
triggered by a Trello webhook or a GitHub webhook.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* docs: add GitHub webhook integration documentation

Adds comprehensive documentation for GitHub webhook setup:
- GitHub webhook endpoint in API endpoints section
- Detailed setup instructions with configuration steps
- List of supported GitHub triggers and their behavior
- Updated features list to include GitHub integration

This complements the recent GitHub webhook improvements including
PR review submission support and automatic card movement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: redis startup fails due to nologin shell (#15)

The redis user has /usr/sbin/nologin as its default shell, which
prevents `su redis -c` from working. This was causing Redis to fail
to start in production with "This account is currently not available."

Fix by using `su -s /bin/sh` to explicitly specify a shell for the
redis user when starting the service.

Also updated agent environment documentation to reflect the correct
startup command.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
zbigniewsobiecki added a commit that referenced this pull request Jan 2, 2026
* feat: add Redis configuration and startup for agents (#13)

Add Redis support alongside PostgreSQL, enabling agents to use in-memory
data storage for caching, queues, and session management.

Changes:
- Install redis-server and redis-tools in Docker image
- Configure Redis with AOF persistence, 256MB memory limit, and LRU eviction
- Add startRedis() function following the same pattern as startPostgres()
- Integrate Redis startup into agent lifecycle (base.ts, review.ts)
- Document Redis CLI commands and usage in agent prompts
- Both PostgreSQL and Redis are critical: agents fail if either service doesn't start

Redis configuration:
- Port: 6379 (standard)
- Bind: localhost only for security
- Persistence: AOF with everysec fsync
- Memory: 256MB with allkeys-lru eviction policy
- Access: via redis-cli through Tmux gadget

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: increase post-job grace period to allow debug agent webhooks

The debug agent wasn't triggering because CASCADE was shutting down too
quickly after uploading session logs. Trello webhooks for attachment uploads
take a few seconds to arrive, but we were only waiting 5 seconds before
shutting down the machine.

Increased postJobGracePeriodMs from 5s to 45s to ensure:
1. Agent uploads session log attachment
2. Trello webhook is delivered while machine is still running
3. Debug agent trigger processes the webhook
4. Debug agent runs before shutdown

This fixes the race condition where attachment webhooks arrived after
the machine had already shut down.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* feat: add support for GitHub PR review submission webhooks

Both pull_request_review (review submission) and pull_request_review_comment
(review comments) now trigger the review agent for PRs with Trello card URLs.

Changes:
- Updated webhook queue to store event types alongside payloads
- Added PRReviewSubmittedTrigger for review submissions (approve/request changes)
- Fixed hardcoded event type in GitHub webhook dequeuing
- Both review types now trigger the review agent when PR has Trello card URL

Previously, only review comments triggered the agent. Now review submissions
(when someone clicks 'Approve' or 'Request Changes') also trigger it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: move cards to IN REVIEW after PR creation from GitHub webhooks

Adds automatic card movement logic to executeGitHubAgent that mirrors
the existing behavior in Trello webhook handler. When implementation
agent creates a PR, the card is now moved to the IN REVIEW list and
a comment with the PR URL is added.

This ensures consistent behavior regardless of whether the agent was
triggered by a Trello webhook or a GitHub webhook.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* docs: add GitHub webhook integration documentation

Adds comprehensive documentation for GitHub webhook setup:
- GitHub webhook endpoint in API endpoints section
- Detailed setup instructions with configuration steps
- List of supported GitHub triggers and their behavior
- Updated features list to include GitHub integration

This complements the recent GitHub webhook improvements including
PR review submission support and automatic card movement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: redis startup fails due to nologin shell (#15)

The redis user has /usr/sbin/nologin as its default shell, which
prevents `su redis -c` from working. This was causing Redis to fail
to start in production with "This account is currently not available."

Fix by using `su -s /bin/sh` to explicitly specify a shell for the
redis user when starting the service.

Also updated agent environment documentation to reflect the correct
startup command.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <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