Skip to content

test(auto-reply): expect the persona icon that replies actually carry - #125

Merged
cryptolir merged 1 commit into
mainfrom
fix/auto-reply-persona-tests
Aug 15, 2026
Merged

cryptolir merged 1 commit into
mainfrom
fix/auto-reply-persona-tests

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

main's unit suite is red, and has been for a while

8 tests assert reply text without the persona icon that runReplyAgent has been adding since b60f19809. resolvePersonaIcon always returns an icon — it falls back to the default persona — and applyPersonaPrefix (agent-runner.ts:540) applies it unconditionally, so every non-empty reply is prefixed. The assertions predate the feature.

Why nobody noticed

The code jobs only run on code-touching PRs, and recent merges to main have been docs-only. The last green CI run on main (016cb77d) skipped checks, checks-windows, check and build-artifacts entirely — only check-docs, docs-scope and secrets ran.

A green tick on main did not mean the tests had run. I initially misread that tick as evidence these failures were mine; they were not.

Two fixes, because the tests differ in what they test

tests fix why
agent-runner.misc.runreplyagent, reply.block-streaming name the prefix via a PERSONA_PREFIX constant they assert the delivered payload — the icon is genuinely on the wire, so they should say so. One constant to change if the default icon moves.
reply.media-note, reply.raw-body strip it via a new exported stripPersonaIcon the text is an incidental "a reply came back" check while testing prompt plumbing and directive parsing — not personas.

A pre-existing bug this surfaced (not fixed here)

reply.media-note resolves to the finance icon 🤖💵, which it should not. hasKeyword is a plain substring match (persona.ts:88-91):

return keywords.some((keyword) => haystack.includes(keyword));

So "eth" matches "whether", "sol" matches "console", "trade" matches "traded". Ordinary words will mis-route the persona icon in production.

I deliberately did not hardcode 🤖💵 into that test, because it would enshrine the misfire. I also have not changed the heuristic — word-boundary matching is a product decision, not a test fix. Flagging it for a follow-up.

Verification

  • 6614 / 6615 unit tests pass (was 6607 / 6615).
  • oxlint clean on all 5 changed files.
  • No new tsc errors (the 2 in server.chat.gateway-server-chat-b.e2e.test.ts are pre-existing on main, verified by stashing).

The one remaining local failure is not a real one: discovery.test.ts "blocks suspicious ownership when uid mismatch is detected" fails only because I ran the suite as root. The check trusts root-owned files by design (discovery.ts:127-128, stat.uid !== params.uid && stat.uid !== 0), so a root-created fixture is legitimately not blocked. It passes on CI's non-root runner — deliberately untouched.

Review asks

  1. Is naming the prefix right for the payload tests, or should they strip it too? I split by intent, which is a judgement call worth a second opinion.
  2. stripPersonaIcon is a new production export used only by tests. Reasonable (it is symmetric with applyPersonaPrefix and reuses the existing ICON_PREFIX_RE), or should it live in a test helper?
  3. The substring-matching bug — worth a follow-up issue, or do you want word-boundary matching in this PR?

@codex review

The unit suite is red on main: 8 tests assert reply text without the persona
icon that runReplyAgent has been adding since b60f198. resolvePersonaIcon
always returns an icon — it falls back to the "default" persona — and
applyPersonaPrefix (agent-runner.ts:540) applies it unconditionally, so every
non-empty reply is prefixed. The assertions predate the feature.

This went unnoticed because the code jobs only run on code-touching PRs, and
recent merges to main were docs-only: the last green CI run on main skipped
checks, checks-windows, check and build-artifacts entirely. A green tick on main
did not mean the tests had run.

Two different fixes, because the tests differ in what they are about:

- agent-runner.misc.runreplyagent and reply.block-streaming assert the delivered
  payload, so they now name the prefix through a PERSONA_PREFIX constant — one
  place to change if the default icon moves.
- reply.media-note and reply.raw-body only use the text as an incidental "a
  reply came back" check while testing prompt plumbing and directive parsing.
  They strip the icon via a new exported stripPersonaIcon, rather than hardcode
  one. media-note resolves to the FINANCE icon, and it should not: hasKeyword is
  a plain substring match (persona.ts:88-91), so "eth" matches "whether" and
  "sol" matches "console". Baking that into an unrelated test would enshrine a
  misfiring heuristic. The heuristic itself is left alone here — it is a product
  decision, not a test fix.

6614 of 6615 unit tests now pass. The one remaining failure,
discovery.test.ts "blocks suspicious ownership when uid mismatch is detected",
is an artifact of running the suite as root: the check trusts root-owned files
by design (discovery.ts:127-128, `stat.uid !== params.uid && stat.uid !== 0`),
so a root-created fixture is legitimately not blocked. It passes on CI's
non-root runner and is deliberately untouched.

Co-Authored-By: Claude Opus 5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 20b3554b32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cryptolir
cryptolir merged commit ba26104 into main Aug 15, 2026
18 of 24 checks passed
@cryptolir
cryptolir deleted the fix/auto-reply-persona-tests branch August 15, 2026 19:20
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