feat(slack): tighten mention tokens and nudge toward PRs for code-fixable issues#2691
Merged
Conversation
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/agent/src/server/agent-server.ts:1746-1747
The PR-nudge instruction is included in `identityInstructions` for every Slack-origin run, including those where `createPr` is `false`. In that mode the main body of the prompt explicitly forbids creating PRs ("Do NOT create a branch, commit, push, or open a pull request unless the user explicitly asks"), so the agent receives contradictory guidance: proactively offer a PR vs. never open one. The nudge should be gated on `shouldAutoCreatePr`, which is already computed above the string.
```suggestion
${shouldAutoCreatePr ? `
# Suggesting code changes
You can also open pull requests directly from this Slack thread. When the user's question describes a problem with a plausible code-side fix — a bug visible in errors or logs, missing or broken instrumentation, a broken funnel step traceable to UI code, a stale config that lives in a repo — end your reply with a one-sentence offer to open a PR for the fix and ask if they want you to proceed. Skip the offer for pure data lookups with no actionable code change (e.g. "what was DAU yesterday?"), and skip it when the fix would clearly live outside any repo you can reach.` : ""}
```
Reviews (1): Last reviewed commit: "feat(slack): nudge users toward opening ..." | Re-trigger Greptile |
Tighten the Slack-origin system prompt rule on user mentions: require that the `<@U…|displayname>` token come from the thread context verbatim, and explicitly forbid substituting the display name (or any other string) for the `U…` ID. Falls back to plain text when no labeled token exists. Follow-up to #2676: the agent learned the token's shape but invented the user ID — observed in a Slack reply rendering `<@paul|Paul D'Ambra>`, which Slack doesn't ping.
75f1500 to
b9cb6a1
Compare
2 tasks
Contributor
|
Reviews (2): Last reviewed commit: "chore(slack): swap real name in mention ..." | Re-trigger Greptile |
andrewm4894
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small Slack-origin system prompt tweaks in the cloud agent (both gated on
getCloudInteractionOrigin() === "slack").Companion to PostHog/posthog#64226, which restructures the Slack thread context the agent sees: messages are rendered as
<@U…|displayname>:followed by an indented body, with role annotations like "Thread started by" / "Tagged the PostHog app". The labeled mention tokens that show up in that context block are what this PR teaches the agent to reuse verbatim.1. Mention tokens — forbid fabrication
PR #2676 told the Slack-bound agent the labeled Slack mention format (
<@U…|displayname>) and instructed it to copy tokens verbatim from context. In practice the agent learned the shape but still invented user IDs when the same person came up later in its reply.Observed example: in a single reply the agent emitted
<@U02DXFTVDNE|displayname>correctly in the first paragraph (copied from context), then<@displayname|displayname>in the second paragraph — substituting the display name for theU…ID. Slack does not render the second form as a real ping.This PR tightens the rule:
U…ID is explicitly disallowed, with the bad and good forms shown.2. Suggesting code changes
Adds a short instruction to the Slack-only identity block: after answering, if the question describes a plausibly code-fixable issue (bug in errors/logs, broken instrumentation, funnel step traceable to UI code, stale repo config), offer to open a PR. Skipped for pure data lookups and when no reachable repo could host the fix.
Goal: surface PostHog Code's PR-opening capability to Slack users who currently only use the analytical side.