Fix: pass httpHeaders to streamable HTTP transport#167
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds passing of configured HTTP headers into the streamable MCP HTTP transport; adds Slack client thread-tracking for follow-ups and hardens final assistant-text extraction/filtering before sending. Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
28dd8bd to
173c0aa
Compare
The HTTP transport was ignoring httpHeaders from config, causing auth failures for MCP servers that require Bearer token auth (e.g., Omni). Uses aliased import to avoid shadowing the 'transport' parameter name. Fixes tuannvm#166 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Tyson Woeste <tyson@belliwelli.com>
173c0aa to
3beae6c
Compare
The agentCallbackHandler.HandleChainEnd was sending every intermediate agent step to the user, including internal "Thought:", "Action:", and "Action Input:" reasoning text. This changes the handler to: 1. Suppress intermediate tool-calling steps (containing Action/Action Input) 2. Strip the "Thought: Do I need to use a tool? No / AI:" prefix from the final answer 3. Only send the clean final response to the user Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Tyson Woeste <tyson@belliwelli.com>
Track active threads when the bot is @mentioned, then respond to follow-up messages in those threads without requiring another @mention. This gives natural flowing conversation in threads. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@internal/slack/client.go`:
- Line 40: activeThreads currently uses map[string]bool and is never evicted,
causing unbounded growth; change it to store timestamps (e.g.,
map[string]time.Time or map[string]int64) instead of bool, update the code paths
that insert keys (the AppMentionEvent handling where entries are added) to write
time.Now(), and add a pruning strategy — either a simple TTL-based prune helper
that removes entries older than N (called periodically via a background
goroutine or lazily on writes/reads), or replace with a bounded LRU structure;
ensure all access to activeThreads is protected by the existing mutex (or add
one) when reading/writing to avoid races.
| historyLimit int | ||
| discoveredTools map[string]mcp.ToolInfo | ||
| tracingHandler observability.TracingHandler | ||
| activeThreads map[string]bool // channel:threadTS keys where bot has been mentioned |
There was a problem hiding this comment.
Unbounded growth of activeThreads map — entries are added but never evicted.
Every AppMentionEvent inserts a key into activeThreads, but there is no expiration, size cap, or cleanup path. For a long-running bot in an active workspace this map will grow indefinitely, leaking memory.
Consider one of:
- A TTL-based eviction (e.g., remove entries older than N hours using a timestamp value instead of
bool). - A bounded LRU / ring buffer.
- Periodic pruning in a background goroutine.
Example: store timestamps and add a simple pruning helper
- activeThreads map[string]bool // channel:threadTS keys where bot has been mentioned
+ activeThreads map[string]time.Time // channel:threadTS → last-activity time- c.activeThreads[threadKey] = true
+ c.activeThreads[threadKey] = time.Now()- isActiveThread = c.activeThreads[threadKey]
+ if ts, ok := c.activeThreads[threadKey]; ok && time.Since(ts) < 24*time.Hour {
+ isActiveThread = true
+ }And periodically (or lazily) prune stale entries.
Also applies to: 269-273
🤖 Prompt for AI Agents
In `@internal/slack/client.go` at line 40, activeThreads currently uses
map[string]bool and is never evicted, causing unbounded growth; change it to
store timestamps (e.g., map[string]time.Time or map[string]int64) instead of
bool, update the code paths that insert keys (the AppMentionEvent handling where
entries are added) to write time.Now(), and add a pruning strategy — either a
simple TTL-based prune helper that removes entries older than N (called
periodically via a background goroutine or lazily on writes/reads), or replace
with a bounded LRU structure; ensure all access to activeThreads is protected by
the existing mutex (or add one) when reading/writing to avoid races.
When an MCP tool call fails (e.g., 504 timeout, auth error), return the error message as a tool result string instead of a Go error. This lets the LLM agent see what happened and retry or use a different approach, rather than crashing the entire agent loop and returning an error to the user. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of a static "Querying Cerebro..." indicator, randomly pick from a pool of short phrases like "On it...", "Digging in...", "Crunching..." etc. The cleanup logic matches against any known thinking message. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two changes that prevent the agent loop from crashing when Claude produces non-conformant ReAct output: 1. Enable ParserErrorHandler on the executor so parse failures get fed back to the LLM as observations instead of killing the loop. The LLM can self-correct on the next iteration. 2. Make JSON unmarshal errors in mcpTool.go non-fatal, same pattern as the existing MCP call error resilience. Returns the error as a tool result string so the LLM can retry with valid JSON. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Handle socketmode.EventTypeSlashCommand in the event loop. For /cerebro-status, proxy to the local status-server sidecar on localhost:8081 and return Block Kit JSON via Ack. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
httpHeadersfrom config to the MCP client viatransport.WithHTTPHeaders()Problem
MCP servers requiring Bearer token auth (e.g., Omni) fail with
Authentication requiredwhen using thehttptransport because headers aren't forwarded.Fixes #166
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes