feat(slack): send agent turn parts alongside joined text on /relay_message#3048
Conversation
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
…ssage SessionLogWriter already collects each turn's assistant messages as an array of separate text blocks (one per message between tool_calls). It only joins them with "\n\n" at read time. Expose the pre-join array as getAgentResponseParts and pass it to /relay_message as an optional text_parts field. Backend-side follow-up: prefer text_parts[-1] over the joined text so only the post-last-tool-use answer lands in Slack, not every "Let me check…" interim narration. Older backends ignore the new field and keep using text, so this is safe to ship independently. Question relays (relaySlackQuestion) still send a single formatted string — no parts needed there.
219bf9b to
eee448f
Compare
| const messageParts = this.session.logWriter.getAgentResponseParts( | ||
| payload.run_id, | ||
| ); |
There was a problem hiding this comment.
can we gate this to slack only? this would run across cloud runs right? 🤔
if this relay is still gated all good
There was a problem hiding this comment.
yeah, the relay endpoint is gated only for slack aka if no slack thread task mapping exists, we skip.
|
Reviews (2): Last reviewed commit: "feat(slack): send agent turn parts along..." | Re-trigger Greptile |
Problem
The Slack agent's initial reply posted the whole assistant turn including the "Let me pull DAU…" narration before each tool call. Slack should see only the final answer.
Changes
SessionLogWriteralready collects each assistant text block intocurrentTurnMessagesbefore joining them at read time. Expose that raw list viagetAgentResponseParts()and pipe it to the backend astext_partsalongside the existing joinedtextfield.The backend (PostHog/posthog#67297) posts the last non-empty
text_partsentry when present, so only the post-last-tool-use text reaches Slack.textstays as the fallback for backends that don't understandtext_partsboth sides ship in either order.Only the initial-reply site (
agent-server.ts) sendstext_parts; the Slack-question relay path is untouched (single formatted question, no interim narration to trim).How did you test this?
Automated only (agent, no manual testing claimed):
getAgentResponsePartsunit tests: returns each turn message as a separate entry; returnsundefinedfor empty/unregistered sessions.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Model: Claude Opus 4.7 (1M context).