feat(integrations): add Slack bot runtime tools#4060
Conversation
Greptile code reviewThis repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md. Run a review — add a PR comment with: Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5. Optional: automate with the greploop skill. |
|
@greptile review |
…e-tools # Conflicts: # integrations/slack/tools/__init__.py
Greptile SummaryThis PR adds three new tools (inspect Railway deployment, redeploy Railway service, replay Slack thread) along with the necessary Railway integration plumbing — CLI client, config model, verifier, catalog wiring, and docs. The implementation follows established patterns throughout: subprocess isolation with a timeout, credential redaction before error surfacing, explicit
Confidence Score: 5/5Safe to merge; all new paths are additive and do not touch existing functionality. The Railway and Slack additions are self-contained, the confirmation guard on redeploy is correctly enforced, credential redaction covers all token sources, and the cursor-pagination cycle guard works correctly. The truncated flag underreports on the last page when the cap is hit mid-page, but this only affects the metadata field — no messages are lost from the response and no downstream state is corrupted. integrations/slack/thread_client.py — the truncated flag logic Important Files Changed
Sequence DiagramsequenceDiagram
participant LLM as LLM Planner
participant IT as InspectRailwayDeploymentTool
participant RT as RedeployRailwayServiceTool
participant RC as RailwayClient
participant CLI as Railway CLI
participant ST as ReplaySlackThreadLocallyTool
participant TC as thread_client
participant SA as Slack API
LLM->>IT: run(project, service, environment)
IT->>RC: resolve_scope_object()
RC-->>IT: RailwayScope
IT->>RC: inspect_deployment(scope)
RC->>CLI: railway deployment list --limit 100 --json
CLI-->>RC: JSON list
RC->>RC: _deployment_record() max by createdAt
RC-->>IT: DeploymentInfo
IT-->>LLM: "{status:ok, deployment:{...}}"
LLM->>RT: "run(project, service, environment, confirm=true)"
RT->>RC: resolve_scope_object()
RC-->>RT: RailwayScope
RT->>RC: redeploy(scope)
RC->>CLI: railway redeploy --yes --json
CLI-->>RC: "{id: new-deployment-id}"
RC-->>RT: RedeployInfo
RT-->>LLM: "{status:ok, redeploy:{deployment_id:...}}"
LLM->>ST: "run(thread_ref=C123/1234567890.123)"
ST->>TC: parse_thread_ref()
TC-->>ST: (channel, timestamp)
ST->>TC: fetch_thread(channel, timestamp)
loop cursor pagination up to 500 msgs
TC->>SA: GET conversations.replies
SA-->>TC: "{messages, response_metadata.next_cursor}"
TC->>TC: redact_slack_token(message.text)
end
TC-->>ST: "{messages, truncated}"
ST-->>LLM: "{status:ok, thread:{...}}"
Reviews (5): Last reviewed commit: "style(slack): order replay tool imports" | Re-trigger Greptile |
|
@greptile review |
|
@greptile review |
…e-tools # Conflicts: # tests/integrations/test_registry.py
|
@farizanjum can you work a running demo for this? a screen recording? this was mentioned in the PR submission guidelines |
|
@muddlebee Sorry for missing the demo in the initial submission. I have resolved the current merge conflict and will attach a short, trimmed terminal recording to this PR shortly. It will show the real Railway deployment inspection, Slack thread replay, redeploy confirmation guard, and focused tests. |
|
@muddlebee I have now attached the requested demo recording to the PR description. It shows the real Railway deployment inspection with commit metadata, Slack thread replay pagination, the redeploy confirmation guard, and the focused test run. Please take another look when you have a chance. |
|
thank you, I will review shortly. looks good overall |
muddlebee
left a comment
There was a problem hiding this comment.
Issue #3230 acceptance is mostly covered (inspect / replay / confirmed redeploy, vendor-first placement, solid tests). Blocking follow-ups: Slack token resolution should share bot_api helpers, and thread_client should harden null reactions/messages. Also tighten Railway SUCCESS search beyond the newest 20 rows and fail closed when redeploy JSON has no deployment id.
| "ts": item.get("ts", ""), | ||
| "reactions": [ | ||
| reaction.get("name", "") | ||
| for reaction in item.get("reactions", []) |
There was a problem hiding this comment.
item.get("reactions", []) returns None when Slack sends "reactions": null, so this listcomp raises TypeError outside the httpx try/except. Same risk on payload.get("messages", []) above. Use (item.get("reactions") or []) and (payload.get("messages") or []), matching integrations/slack/bot_api.py.
|
|
||
|
|
||
| def fetch_thread(channel: str, timestamp: str) -> dict[str, Any]: | ||
| token = os.getenv("SLACK_BOT_TOKEN", "").strip() |
There was a problem hiding this comment.
Only reads process env. Other Slack bot tools resolve via resolve_bot_token() (env + keyring + integration store). Wizard-configured tokens will fail here while slack_read_messages works. Prefer resolve_bot_token / bot_token_configured from integrations.slack.bot_api, and reuse its conversations.replies helper instead of a parallel httpx client.
| outputs = {"thread": "Captured Slack thread messages.", "error": "Failure detail."} | ||
|
|
||
| def is_available(self, _sources: dict[str, dict[object, object]]) -> bool: | ||
| return bool(os.getenv("SLACK_BOT_TOKEN", "").strip()) |
There was a problem hiding this comment.
Gate availability with bot_token_configured(sources) like the other Slack bot tools. os.getenv alone hides this tool when the token lives in the keyring or integration store.
| "--environment", | ||
| scope.environment, | ||
| "--limit", | ||
| "20", |
There was a problem hiding this comment.
--limit 20 then filtering to SUCCESS can report deployment_unavailable when the only successful deploy is older than the newest 20 failed/removed rows. Raise the limit or page until a SUCCESS is found.
|
@farizanjum pls check check docs here https://www.opensre.com/docs/integrations-overview |
…e-tools # Conflicts: # integrations/config_models.py
|
@greptile review |
|
The requested Railway-first refactor and upstream
Verification completed:
Please take another look when you have a chance. |
Fixes #3230
Summary
Demo
Testing
Code Understanding and AI Usage
Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?
If you used AI assistance:
Explain your implementation approach:
I split the issue into three focused tools so read-only inspection and replay do not inherit redeploy approval requirements. Railway operations use explicit project, service, and environment selectors without writing Railway link state into the workspace. The replay tool follows Slack cursors with a bounded result, and both external boundaries return structured errors with credential redaction. The tools live under their respective vendor integrations because each tool directly calls only one vendor.
Checklist before requesting a review
Demo
opensre-issue3230-demo.mp4
a8faaa54and messagefeat: add Railway health demo.Testing
uv run python -m pytest tests/integrations/test_registry.py tests/integrations/test_vendor_first_layout.py tests/tools/test_slack_bot_runtime_tool.py tests/tools/test_registry_index.py tests/tools/test_telemetry.py -q --tb=short --basetemp=.pytest_tmp -p no:asynciouv run python -m ruff check config core gateway integrations platform surfaces tools testsuv run python -m ruff format --check config core gateway integrations platform surfaces tools testsuv run python -m mypy config core gateway integrations platform surfaces tools