Would it be possible to basically flag when we have a new turn, we should flag if any of…
- User
Would it be possible to basically flag when we have a new turn, we should flag if any of our messages ever pre-received the reaction since the previous turn. We should just flag that as well somehow. Can you think two have to do this?
- Assistant
I’ll trace how turns, messages, and reactions are represented first, then I’ll outline a concrete implementation path that fits the existing data flow.
- Assistant
The repo already has Discord reaction ingestion and a pacing-events table, so the likely path is to turn those reaction rows into per-turn context instead of inventing a separate channel. I’m reading that flow now to see where the handoff into an agent turn happens.
- Assistant
Yes. There are two reasonable ways to do it.
Best fit: add a per-turn hot-context flag.
Reactions are already persisted as
feedbackrows withsource='reaction'when a user reacts to one of our outbound messages in app/services/inbound.py and app/services/discord.py. On each new agent turn,build_hot_context(...)in app/services/hot_context.py can query: - User
No, I don't think reactions should trigger stuff. I think they should be more passive when the next message comes in as well. Like what you suggest. Can you please implement that, please?
- Assistant
I’ll implement this as passive hot context: reaction feedback will be surfaced only when some later turn is already being built, and it won’t enqueue or trigger anything by itself. I’m going to keep it bounded and privacy-conscious, similar to recent messages.
- Assistant
The relevant detail is that
build_hot_contextruns before the newbot_turnsrow is opened, so “since the previous turn” should be computed against the latest completed turn for that same user. I’m adding a small hot-context field plus rendering/tests, not changing the webhook behavior. - Assistant
I’m going to edit
hot_contextto collect and render a bounded list of new reaction feedback, then add a migration index and focused tests. - Assistant
The core code and fake DB support are in place. I’m running the hot-context tests now, then I’ll run a smaller lifecycle check to catch fake-pool interactions.
- Assistant
The lifecycle tests passed, and the hot-context failure is in the test fixture shape: its “outbound” row is addressed to the partner, while reaction feedback should be on bot messages sent to the current user. I’m tightening that fixture setup rather than weakening the production filter.
- Assistant
The targeted behavior tests pass now. I’m doing a quick formatting/lint sanity pass on the touched files and checking the diff for any accidental noise.
- Assistant
ruffhit the machine’s pyenv default (3.8.10is missing), not a code error. I’m retrying with the installed Python version so we still get the lint signal. - Assistant
Lint passes with the installed Python. I’m running the full test suite once because this path touches shared hot-context construction.
- Assistant
Implemented.
What changed:
- Added passive
recent_reactionsto hot context in hot_context.py. - It surfaces reactions only during the next normal turn, based on reaction feedback created after the latest completed turn for that same user.
- It renders a bounded section:
## New reactions since previous turn. - It explicitly tells the model to treat them as passive feedback and not mention them unless naturally relevant.
- Added 0019_feedback_reaction_context.sql with an index for reaction lookups.
- Added test coverage and fake DB support.
Validation:
uv run pytestpassed:395 passed, 3 skipped.PYENV_VERSION=3.11.11 uv run ruff check app/services/hot_context.py tests/test_hot_context.py tests/conftest.pypassed.
- Added passive
- User
and does it have a way to schdeule things for a period - e.g. for the next month?
- Assistant
I’ll check the scheduler/task tooling rather than guessing, since the distinction between one-off, recurring, and bounded-period schedules matters here.
- Assistant
Yes. It supports bounded recurring scheduled tasks, not a single “period” field.
The recurrence model supports:
hourly,daily, orweeklyinterval, like every 2 daysuntil, a timezone-aware end datetimeremaining_occurrences
So “for the next month” would be represented as recurrence with an
untilabout one month out. Example shape:json{ "brief": "Check in about X", "local_when": { "date": "2026-05-09", "time": "09:00:00", "timezone": "Europe/Berlin" }, "recurrence": { "type": "daily", "interval": 1, "until": "2026-06-08T09:00:00+02:00" } }Weekly also works, e.g. Mondays and Fridays for the next month:
json{ "type": "weekly", "interval": 1, "weekdays": [0, 4], "until": "2026-06-08T09:00:00+02:00" }So the scheduler can do it, but the interface is “repeat until X” or “repeat N occurrences,” not “period: next_month.”
- User
does it know about this in its system prompt?
- Assistant
I’ll verify the actual prompt/tool descriptions, because the scheduler capability exists in schemas but the model only knows it if the prompt or tool description makes it clear.
- Assistant
It has partial knowledge: the system prompt says when to schedule and which scheduling tool to use, and the tool schema exposes
recurrence.until/remaining_occurrences. It does not currently say, in plain prompt language, “for the next month means a recurrence with anuntilbound,” so I’m going to make that explicit. - User
and have a way to query the dates (e.g. what date is one month from today) or communicate in relative time like we do elsewhere?
- Assistant
I’ll check the existing time-reference helpers and scheduled-task outputs, because we may already expose relative labels for stored jobs but not a general date-calculation affordance for planning a new bounded recurrence.
- Assistant
The code already formats many stored timestamps with
*_timerelative labels, and scheduled tasks exposescheduled_for_time. The gap is that recurrence end dates are just raw datetimes, and hot context does not provide a precomputed “one month from now/today” anchor, so I’m adding those instead of relying on the model to do calendar math unaided. - Assistant
I’ve added the date anchor and recurrence-end rendering. Now I’m running the focused tests and lint to catch schema or prompt fallout.
- Assistant
Focused tests and lint pass. Since
tool_schemas.pychanged, I’m running the full suite once more to make sure no generated tool validation assumptions break. - Assistant
Yes, now it does.
I added:
- A calendar-safe
add_calendar_months(...)helper, so “one month from today” clamps correctly for month ends. - Hot context now includes
one_month_from_nowanchors: local datetime, UTC datetime, and local date. - The scheduling prompt now tells the model to use those anchors for phrases like “for the next month.”
- Scheduled-task rows now expose
recurrence_until_time, matching the relative/local*_timepattern used elsewhere.
Validation:
uv run pytestpassed:396 passed, 3 skipped.- Ruff passed on touched files.
- A calendar-safe