Skip to content

fix(auto-reply): port reply-content guards for confusion and uninspected photos - #64

Merged
twoimo merged 11 commits into
mainfrom
fix/port-reply-content-guards
Nov 23, 2026
Merged

twoimo merged 11 commits into
mainfrom
fix/port-reply-content-guards

Conversation

@twoimo

@twoimo twoimo commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Why

Every open PR in twoimo/alden should be resolved on its merits. The 22 stale codex/alden-* draft PRs come from a forked lineage that cannot merge as-is, and they will be closed. Before they close, their unique fixes that are still useful get ported to main. This PR ports two reply-content safety fixes for the KakaoTalk auto-reply worker. Without them the worker can send a reply that claims something it does not know.

Ported from origin/codex/alden-explicit-references-20261025:

  • 0003e92 "Ground Kakao confusion replies and preserve pre-send checks"
  • 8ceeea8 "preserve Alden turns and reject uninspected image replies". Only the scripts/auto-reply-worker.py and tests/test_auto_reply_cli_runtime.py parts are ported. The Alden desktop and voice parts are left out.

Both fixes were rewritten against main's current code. The lineage hunks were not pasted in.

What changes

A generic confusion reply is never sent. On main, _policy_valid_draft rejected "무슨 말인지 모르겠네요" only when the inbound turn was punctuation and a grounded topic existed. So "그래서?", a bare "???", or "아 그렇구나" with no context sent it. Now the full policy rejects every generic confusion draft, and the fallbacks skip it. The matcher covers both 되 and 돼 spellings, including the common misspellings "안 되요" and "안 돼네(요)".

When no draft passes the full policy and at least one draft was a confusion line, the worker sends a clarification. It does not fall back to another draft that the full policy also refused. The clarification is the grounded "아까 “…” 얘기야?" when a topic exists. Otherwise it is "어떤 얘기인지 조금만 더 말해줘" ("말씀해 주세요" for honorific recipients), or the honest photo reply below on an image turn. The question_unknown, photo_passthrough and lenient_policy fallbacks are reached only when no confusion draft was involved. That keeps main's behavior there. The clarification wording is deliberately not a question, so it passes the unchanged pre-send _policy_valid_draft recheck (question_unanswered rejects a question reply to a non-question turn). No pre-send safeguard is bypassed.

No invented remarks about a photo nobody inspected.

  • _photo_fallback_reply picked a stock visual remark ("화질이 별로네", "색감이 별로네"). It now returns "사진 내용을 확인하지 못했어. 필요한 부분은 글로 알려줘", or the honorific form when the current recipient needs it. Main decided the register from whoever spoke earlier in the room.
  • On a photo turn whose images all failed to load, _run_opencodex_generation_unleased still sent a text-only request. It now sends nothing and returns image_input_unavailable. generate_reply releases that call's lease without opening a cooldown or clearing earlier failures (_release_unsent_model_call), and returns image_unavailable.
  • The same holds when the image model is in cooldown and a fallback vision model is the one that cannot load the images. That candidate ends the fallback chain with its lease open, and generate_reply releases it once, after every fallback branch, without a failure. No fallback model is charged for a request it never received, and the primary's own unsent request never consults the chain.
  • analyze_event answers that photo turn with the honest photo reply in the recipient's register instead of skipping it. An authorized sender is never skipped. The decision records model_invoked: false and reason media_unavailable_clarification, so the reply stays out of behavior memory like main's existing no-pixel clarification.
  • A text turn keeps main's behavior. analyze_event attaches the same author's recent photos to a text message. If those files cannot be read, the text request still goes out with main's note that the photos could not be read (images_required is true only when attachment == "image"). A text turn never gets the photo apology.

Evidence

Each fix was shown red before it landed.

Second review round. 84432fa and 1708696 add the tests. 0d43585, 8f56f1a and b702efa turn them green. 42bded1 updates a test fake that mirrors _run_generation_candidate's signature.

Red on 84432fa, except the cap test, which was run on the fixed tree with analyze_event's pre-fix image_paths and gate restored:

FAIL: test_cooldown_fallback_with_no_loadable_image_is_not_charged_a_failure
    self.assertEqual(self._model_failures(module, vision_fallback), 0)
AssertionError: 1 != 0
FAIL: test_text_turn_whose_recent_photos_do_not_load_is_still_answered
AssertionError: Tuples differ: ('reply', '사진 내용을 확인하지 못했어. 필요한 부분은 글로 알려줘') != ('reply', '다이소에서 샀어')
FAIL: test_text_turn_never_gets_the_photo_apology_for_context_photos
AssertionError: 'media_unavailable_clarification' != 'image_unavailable'
FAIL: test_every_spelling_of_not_understanding_is_a_confusion_reply
  7 subtests: 이해가 안 돼 / 이해가 안 돼요 / 이해가 잘 안 돼 / 잘 이해가 안 돼요 / 이해가 안 되요 / 이해가 안 돼네 / 이해가 안 돼네요

The cooldown test seeds a real model circuit with the image model in cooldown and a 27B-family fallback whose images become unreadable after validation. It asserts no gateway or process request, zero failures on the fallback, the primary's one failure unchanged, and the honest photo reply passing the pre-send check. Planted mutations each fail a test: reverting the chain guard, removing the post-fallback release, and letting the primary's unsent request reach the chain (which charged Flash Next a failure).

First review round: 3a02d27 adds the tests on top of the first two port commits. 25d32f8 and 1bac3c3 turn them green.

Red on 3a02d27, before the review fixes:

FAIL: test_removed_confusion_draft_never_promotes_a_rejected_draft (inbound='아 그렇군요', rejected='그치 뭐함?', recipient='현준')
FAIL: ... (inbound='아 그렇구나', rejected='너는 뭐 먹었어?', recipient='MOM')
FAIL: ... (inbound='아 그렇구나', rejected='ㅋㅋㅋㅋ', recipient='MOM')
AssertionError: 'ㅋㅋㅋㅋ' != '어떤 얘기인지 조금만 더 말해줘'
FAIL: ... (inbound='사진', rejected='이거 어디야?', recipient='MOM')
AssertionError: '이거 어디야?' != '사진 내용을 확인하지 못했어. 필요한 부분은 글로 알려줘'
FAIL: ... (inbound='사진', rejected='이거 어디야?', recipient='현준')
FAIL: test_photo_turn_with_no_loadable_image_replies_honestly_without_a_request
AssertionError: 'skip' != 'reply'

Each confusion case first asserts that the full policy rejects the second draft. The photo test runs the real generate_reply through analyze_event and makes the images unreadable after the bundle is validated. It asserts that no gateway or process request is made, that the reply is the honest photo line, and that the pre-send policy accepts it.

The earlier port commits were shown red the same way. Commit 1's tests failed on origin/main ('무슨 말인지 모르겠네요' != '어떤 얘기인지 조금만 더 말씀해 주세요'). Commit 2's tests failed on commit 1 ('이거 잘 안 보이네' != '사진 내용을 확인하지 못했어. ...', and (0, b'') != (1, b'image_input_unavailable')). test_generate_reply_sends_no_request_when_no_image_loads uses the real model circuit seeded with one earlier failure. Three planted variants of the lease handling each fail it.

Reviewer's cases, from select_ranked_reply plus the pre-send check:

Inbound, recipient, drafts main before review fix now
"아 그렇군요", MOM honorific, [confusion, "그치 ㅋㅋ"] confusion line "그치 ㅋㅋ" (lenient) "어떤 얘기인지 조금만 더 말씀해 주세요"
"아 그렇군요", 현준, [confusion, "그치 뭐함?"] confusion line "그치 뭐함?" (lenient) "어떤 얘기인지 조금만 더 말씀해 주세요"
"아 그렇구나", MOM, [confusion, "너는 뭐 먹었어?"] confusion line "너는 뭐 먹었어?" (lenient) "어떤 얘기인지 조금만 더 말해줘"
"사진", MOM, [confusion, "이거 어디야?"] confusion line "이거 어디야?", refused at pre-send, silent skip "사진 내용을 확인하지 못했어. 필요한 부분은 글로 알려줘"
photo turn, no image loads text-only request silent skip honest photo reply, no request
photo turn, image model cooling, fallback cannot load the image text-only request fallback put in cooldown, turn deferred honest photo reply, no request, no failure charged
text turn, attached recent photos unreadable text request with note photo apology text request with note

Every "now" reply passes the pre-send recheck.

Green, with Python 3.11, a scratch HOME, and nice -n 10, one at a time:

  • python3 -m unittest tests.test_auto_reply_cli_runtime: 356 tests, OK.
  • The CI desktop job's python3 -m unittest module list (41 modules): 1383 tests, OK (skipped=9).
  • sh scripts/test-auto-reply-launchd-artifacts.sh: "launchd artifact harness passed", exit 0. It drives a fake launchctl via OPENKAKAO_AUTO_REPLY_LAUNCHCTL.

Not ported

  • Prompt text change from 0003e92. The guard enforces the rule whatever the model drafts.
  • 8ceeea8 also refused a request where only some of the images loaded. This PR refuses only when every image of a photo turn failed to load, which is the defect reported on main.
  • Other confusion phrasings such as "무슨 말인지 모르겠다", "모르겠습니다" and "이해 안 돼" (no 가) are not matched. Only the 되/돼 spelling gap was closed.

🤖 Generated with Claude Code

twoimo and others added 11 commits November 23, 2026 12:11
A draft such as "무슨 말인지 모르겠네요" was rejected only when the inbound
turn was punctuation and a grounded topic existed, so "그래서?" or a bare
"???" with no context could still send it. The question_unknown fallback
and the lenient never-skip fallback also returned it unfiltered.

The full policy now rejects every generic confusion draft, the no-eligible
fallbacks skip them, and when every draft was one of them the worker asks
which topic was meant. The clarification is not phrased as a question, so
the unchanged pre-send policy recheck accepts it for non-question turns.

Ports the intent of 0003e92 from the codex/alden-* lineage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When no draft was eligible, or the model stayed unavailable, or the media
fetch failed, the photo fallback picked a stock visual remark such as
"화질이 별로네" about a photo nobody looked at. It now says the photo was not
checked and asks for the needed part in text, in the current recipient's
register. The wording is not a question, so the unchanged pre-send policy
recheck accepts it for a bare photo turn.

When every image failed to load, the runner still sent a text-only model
request and relied on prompt wording to stop a made-up answer. It now
sends nothing. generate_reply releases that call's lease without opening a
cooldown or clearing earlier failures, and returns image_unavailable.

Ports the worker part of 8ceeea8 from the codex/alden-* lineage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rops out

Two red tests for the review of the reply-content guards.

A confusion draft that the full policy now rejects must not hand the turn
to a second draft that the full policy also rejected. The test feeds the
reviewer's cases ("아 그렇군요" from 현준 with "그치 뭐함?", "아 그렇구나"
with "너는 뭐 먹었어?" or "ㅋㅋㅋㅋ", a bare photo with "이거 어디야?") and
expects the clarification or the honest photo reply, which the pre-send
policy recheck accepts. The old assertion that "ㅋㅋㅋㅋ" goes out through
the lenient fallback is dropped.

A photo turn whose images cannot be read at generation time must still get
an honest reply, with no model request sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The full policy now rejects every generic confusion line, but the
clarification fired only when no other draft existed. With a second draft
the turn fell through to the question_unknown, photo and lenient fallbacks,
which sent that draft even though the full policy had refused it, for
example "그치 뭐함?" to 현준 after "아 그렇군요". For a photo turn the
refused draft also failed the pre-send recheck, so nothing was sent.

When any draft was a confusion line, the worker now sends the
clarification, or the honest photo reply on an image turn, before any
fallback can reuse a refused draft. Both pass the unchanged pre-send
policy recheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When every image of a photo turn failed to load, generate_reply now sends
no model request and returns image_unavailable. analyze_event treated that
as a model no-reply and skipped the turn for good, which broke the rule
that an authorized sender is never skipped.

analyze_event now answers that turn with the photo fallback in the
recipient's register ("사진 내용을 확인하지 못했어. 필요한 부분은 글로
알려줘"), records model_invoked as false, and uses the media-unavailable
clarification reason, so the reply stays out of behavior memory like the
existing no-pixel clarification. Still no model request is sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three rare paths the PR left worse than main or incomplete:

- A cooldown fallback whose images will not load sends nothing, yet the
  chain charged it a runner_failed cooldown and deferred the turn.
- A text turn that carries the author's recent photos got the photo
  apology when those files could not be read, instead of an answer.
- "이해가 안 돼" and the other 돼 or 되요 spellings passed as a valid
  draft.

The analyze_event photo tests share one gateway harness, which also
stubs the local media download and the screen capture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The matcher took only 되, so "이해가 안 돼", "이해가 안 돼요" and the
common misspellings "안 되요" and "안 돼네" went out as valid drafts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A text turn carrying more context photos than the image cap gets
image_unavailable from generate_reply before any request. analyze_event
answered it with the photo apology, which is only for a photo turn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For a text message, analyze_event attaches the same author's recent
photos. When those files could not be read, the runner refused to send
and the turn got "사진 내용을 확인하지 못했어" instead of an answer.

The runner now refuses only when the turn itself is the photo. For a
text turn it sends main's text request with the note that the photos
could not be read, and analyze_event keeps the photo apology for photo
turns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the image model in cooldown, the fallback chain ran a vision
candidate whose images would not load. It sent nothing and returned
image_input_unavailable, which the chain classified as runner_failed.
A healthy model went into cooldown and the turn was deferred.

That candidate now ends the chain with its lease open. generate_reply
checks for an unsent request once, after every fallback branch, and
releases whichever lease is current without a failure, so the turn gets
the honest photo reply. The primary's own unsent request still skips
the chain, now pinned by asserting no fallback model is charged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…date

The retrieval-command test replaces _run_generation_candidate with a
fake that mirrors its signature. 8f56f1a added images_required there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@twoimo

twoimo commented Nov 23, 2026

Copy link
Copy Markdown
Owner Author

Decision: merge.

Evidence:

  • This ports the worker parts of lineage commits 0003e92 and 8ceeea8 from the codex/alden-* drafts being closed. A read-only audit classified both as reply-content safety fixes that main lacked. Main could send a generic "무슨 말인지 모르겠네요" to a contextless turn, and an invented remark about a photo the model never saw.
  • Every behavior change was red first. The PR body has the test names and assertions.
  • Review history:
    • Review 1 returned FAIL. Removing a confusion draft let the lenient fallback send a draft the full policy had rejected, and a photo turn with no loadable image was skipped silently. Fixed in 3a02d27, 25d32f8 and 1bac3c3.
    • Review 2 returned PASS+NOTES. A fallback model was charged a cooldown for a request it never sent, a text turn could get the photo apology, and the matcher missed the 돼 spelling. Fixed in 84432fa through 42bded1.
    • Review 3, on 42bded1, returned PASS+NOTES. Each lease is released once and never charged for an unsent request. images_required keeps main's behavior for text turns. Every canned line passes _policy_valid_draft in both registers, and none is a question. The confusion matcher does not fire on "그거 돼?", "잘 돼가?" or "안 돼, 내일 가자". Its remaining notes are acceptable behavior changes (sender-based honorifics, and "이해가 안 돼?" replaced by the clarification) or unreachable paths.
  • Local CI on 42bded1 (Python 3.11, scratch HOME):
    • tests.test_auto_reply_cli_runtime passed 356 tests.
    • The CI desktop job's 41-module unittest list passed 1383 tests (9 skipped).
    • sh scripts/test-auto-reply-launchd-artifacts.sh passed.
    • The branch touches no Rust, so the macOS cargo job is unaffected. GitHub-hosted Actions are blocked by billing, so the zero-step check failures are infra state.
  • Production changes only at the next bake.

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