Skip to content

feat(slack): send agent turn parts alongside joined text on /relay_message#3048

Merged
VojtechBartos merged 1 commit into
mainfrom
vojtab/relay-message-text-parts
Jul 1, 2026
Merged

feat(slack): send agent turn parts alongside joined text on /relay_message#3048
VojtechBartos merged 1 commit into
mainfrom
vojtab/relay-message-text-parts

Conversation

@VojtechBartos

@VojtechBartos VojtechBartos commented Jul 1, 2026

Copy link
Copy Markdown
Member

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

SessionLogWriter already collects each assistant text block into currentTurnMessages before joining them at read time. Expose that raw list via getAgentResponseParts() and pipe it to the backend as text_parts alongside the existing joined text field.

The backend (PostHog/posthog#67297) posts the last non-empty text_parts entry when present, so only the post-last-tool-use text reaches Slack. text stays as the fallback for backends that don't understand text_parts both sides ship in either order.

Only the initial-reply site (agent-server.ts) sends text_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):

  • getAgentResponseParts unit tests: returns each turn message as a separate entry; returns undefined for empty/unregistered sessions.
  • Existing session-log-writer and posthog-api tests still pass.
  • Tested locally

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Model: Claude Opus 4.7 (1M context).

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit eee448f.

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff (1)

  1. packages/agent/src/session-log-writer.ts, line 314-329 (link)

    P2 getFullAgentResponse and getAgentResponseParts are now near-identical — they share the same session lookup, empty check, and chunk-buffer warning, differing only in whether they join the array. If the warning block or guard ever needs updating, it must be changed in both places. getFullAgentResponse can simply delegate to the new method instead.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "feat(slack): send agent turn parts along..." | Re-trigger Greptile

…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.
@VojtechBartos VojtechBartos force-pushed the vojtab/relay-message-text-parts branch from 219bf9b to eee448f Compare July 1, 2026 10:59
@VojtechBartos VojtechBartos marked this pull request as ready for review July 1, 2026 11:00
@VojtechBartos VojtechBartos requested a review from a team July 1, 2026 11:01
Comment on lines +3030 to +3032
const messageParts = this.session.logWriter.getAgentResponseParts(
payload.run_id,
);

@tatoalo tatoalo Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we gate this to slack only? this would run across cloud runs right? 🤔

if this relay is still gated all good

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, the relay endpoint is gated only for slack aka if no slack thread task mapping exists, we skip.

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "feat(slack): send agent turn parts along..." | Re-trigger Greptile

@VojtechBartos VojtechBartos merged commit c6d91b5 into main Jul 1, 2026
27 checks passed
@VojtechBartos VojtechBartos deleted the vojtab/relay-message-text-parts branch July 1, 2026 11:40
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.

2 participants