fix(slack): prevent web search context bloat and increase max searches#1523
Conversation
Strip server-side web search content blocks (web_search_tool_result, server_tool_use) from assistant messages before subsequent API calls. The synthesized text already contains the answer, so raw search results aren't needed for tool execution. Also bumps max_uses from 1 to 5.
📝 WalkthroughWalkthroughA helper function Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts (1)
255-263: Double cast (as unknown as) bypasses type safety.The
ContentBlock→unknown→ContentBlockParam[]cast sidesteps structural differences between response and request types in the Anthropic SDK. This works today because the surviving block shapes (text,tool_use) are structurally compatible, but it's fragile against SDK upgrades.Consider mapping each block to its corresponding param type explicitly, or at minimum add a brief inline comment noting why the cast is safe (i.e., which block types survive the filter and why they're param-compatible).
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
web_search_tool_resultandserver_tool_useblocks from assistant messages before subsequent API calls in the Slack agent tool loop, preventing context from blowing up when the model searches the web and then uses client-side tools (e.g., create_task)max_usesfrom 1 to 5 so the model can perform multiple searches per requestTest plan
Summary by CodeRabbit
New Features
Bug Fixes