Skip to content

Reply gate: cadence + relationship signals into the decision#12

Open
sanctrl wants to merge 1 commit into
mainfrom
reply-gate-signals
Open

Reply gate: cadence + relationship signals into the decision#12
sanctrl wants to merge 1 commit into
mainfrom
reply-gate-signals

Conversation

@sanctrl

@sanctrl sanctrl commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #10 (the reply gate, now on main). Wires two deterministic, derived-not-fetched signals into the gate's decision input so it sees the loop's tempo and the conversation's footing — not just the recent transcript.

What

  • Cadence — messages in the last 60s + the gap to the previous message. The loop is a rapid-fire phenomenon and the gate was previously blind to timing. Derived from created_at on the messages already fetched for history (no extra round-trip).
  • Relationship — first-contact vs established vs not-yet-replied, derived from the recent window (have both sides spoken? have I replied yet?).

Both render as compact phrases in the decision prompt (Relationship: … / Pace: …), never raw dumps. The system prompt now ties rapid back-and-forth to the no_reply bias.

How

  • ConversationSignals + compute_conversation_signals (reply_gate): pure and defensive (malformed / naive / future timestamps handled), no network call.
  • agent_invoker._build_conversation_history returns (history, raw_messages) from one fetch; _decide_reply derives the signals and passes them through.
  • Still edge-only — nothing new is asked of the AgentChat server (the carrier stays a carrier).

Tested

ruff + mypy + pytest all green. New coverage: signals computation (cadence window, gap, trigger exclusion, defensive timestamp parsing) + prompt rendering; existing wiring tests updated for the (history, raw_messages) shape. 368 passed, 10 skipped.

No version bump — this folds into the unreleased 0.2.3 reply-gate line.

Wire two deterministic, derived-not-fetched signals into the gate input so
the decision sees the loop's tempo and the conversation's footing — not just
the recent transcript.

- ConversationSignals + compute_conversation_signals (reply_gate): pure and
  defensive (malformed / naive / future timestamps handled), computed from the
  messages already fetched for history — no extra round-trip.
    * cadence — messages in the last 60s + gap to the previous message; the
      loop is a tempo phenomenon and the gate was previously blind to it.
    * relationship — first-contact vs established vs not-yet-replied, derived
      from the recent window.
- build_decision_messages renders compact Relationship + Pace lines; the
  system prompt ties rapid back-and-forth to the no_reply bias.
- agent_invoker: _build_conversation_history returns (history, raw_messages)
  from one fetch; _decide_reply derives signals and passes them through.
- tests: signals computation (window, gap, trigger exclusion, defensive
  parsing) + rendering; wiring tests updated for the new return shape.

All deterministic, edge-derived — nothing new asked of the server. No version
bump (still the unreleased 0.2.3 reply-gate change).
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