Skip to content

fix(slack): stop sending thread_id to decopilot — it rejects unknown ids#437

Merged
JonasJesus42 merged 1 commit into
mainfrom
slack-drop-thread-id
May 13, 2026
Merged

fix(slack): stop sending thread_id to decopilot — it rejects unknown ids#437
JonasJesus42 merged 1 commit into
mainfrom
slack-drop-thread-id

Conversation

@JonasJesus42
Copy link
Copy Markdown
Contributor

@JonasJesus42 JonasJesus42 commented May 13, 2026

Summary

Follow-up to #435/#436. The temp-thread_id retry from #435 still fails in production with Thread not found: <name>-<timestamp> — the decopilot endpoint rejects any unknown thread_id, including the temp fallback. The retry just postponed the same error.

Drop thread_id from the request entirely. Without it, the decopilot allocates a fresh thread per call. The slack-mcp already rebuilds conversation context from Slack history on every webhook (buildContextMessages → 1 system message), so the agent stays coherent within a Slack thread/DM without depending on decopilot-side memory.

The userNamethreadId plumbing is kept upstream in llm-handler.ts / eventHandler.ts so we can plug a real thread-create call (cached id per user) later if per-person decopilot memory becomes important.

Test plan

  • Send a DM → pod logs show [LLM] streamAgent <url> (no thread_id).
  • Bot replies on first message (no more 500 Thread-not-found).
  • Slack thread context survives within a thread (verified by sending a 2nd message referencing the first — context comes from buildContextMessages, not decopilot memory).
  • Unrelated agent failures still fall back to the trigger publish as before.

Summary by cubic

Stop sending thread_id to decopilot to eliminate “Thread not found” errors; each call now creates a fresh decopilot thread while Slack-side context continues to be rebuilt per webhook.

  • Bug Fixes
    • Strip thread_id before calling streamAgent; log now shows “(no thread_id)”.
    • Removed temp thread_id retry and access-failure heuristics to avoid repeated 500s.
    • Left upstream userNamethreadId plumbing intact for a future thread-create flow.

Written for commit 160b632. Summary will update on new commits.

…eate threads

After #435 retried with a temp thread_id on 500 Thread-not-found, real
traffic still failed: the decopilot endpoint rejects ANY unknown
thread_id, including the temp <name>-<timestamp> fallback. The retry
just postponed the same error by one round-trip.

Drop thread_id from the request entirely. Without it the decopilot
allocates a fresh thread per call. The slack-mcp already rebuilds
conversation context from Slack history on every webhook
(buildContextMessages -> 1 system message), so the agent stays
coherent within a thread/DM without depending on decopilot-side
memory. The userName -> threadId plumbing is left in place upstream
so we can plug a real thread-create call (cached id per user) in
later if per-person decopilot memory is needed.

Removes the retry helper and access-failure heuristic since we no
longer pass a thread_id that could fail.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@JonasJesus42 JonasJesus42 merged commit e1ed6af into main May 13, 2026
2 checks passed
JonasJesus42 added a commit that referenced this pull request May 13, 2026
…skId (#438)

After #436 switched to the runtime endpoint /api/<org>/decopilot/runtime/stream
(the path the AgentOf binding uses internally) and #437 dropped thread_id,
real traffic hits `streamCore: taskId is required`. The runtime stream is the
resume-a-task path: it expects a pre-existing taskId minted by another call.
For our chat-like webhook flow there is no upstream task.

Go back to /decopilot/stream — the user-facing chat endpoint studio's own
chat UI uses — and parse its custom SSE locally instead of through the
runtime's `streamAgent`. We still omit thread_id (decopilot rejects ids it
did not mint). The handler/event plumbing for userName -> threadId stays
in place so we can wire a real thread-create call later if needed.

Build, types, lint all clean.

Co-authored-by: Claude Opus 4.7 <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