Skip to content

Make replies faster by cutting agent round-trips - #32

Merged
FrancescoCoding merged 7 commits into
masterfrom
perf/fewer-agent-round-trips
Nov 23, 2026
Merged

FrancescoCoding merged 7 commits into
masterfrom
perf/fewer-agent-round-trips

Conversation

@FrancescoCoding

Copy link
Copy Markdown
Owner

Why

Replies that touch Notion were taking 45 to 170 seconds. Looking at real session transcripts, the time goes on model round-trips (about 4 seconds each, 8 to 40 per reply), not on infrastructure. This cuts the number of round-trips and stops the user waiting on work that can happen after the reply.

What changed

  • One data directory. In the container the app runs from /app but the volume is mounted at /data, so the helper scripts and the host were using two different data/ folders. /app/data now links to /data/data, and the scripts find data/ from their own location rather than the current directory. The run log now actually persists, so /stats works in production.
  • get-page-blocks and query-recent --with-blocks. Reading recent sessions with their sets and loads is now one call instead of one per page.
  • Dashboard sync after the reply. sync-dashboard took 9 to 17 seconds inside the agent's turn. The host now runs it in the background once the reply is sent, whenever the run logged rows. HOST_DASHBOARD_SYNC=false restores the old behaviour.
  • One turn per chat. Messages from the same chat run in order, and ones that arrive while a turn is running are merged into the next turn. Scheduled reminders use the same queue.
  • Status message on long runs. After about 9 seconds the bot posts a short line ("Checking your training log..."), edits it as work moves on, and removes it when the reply lands. PROGRESS_UPDATES=false turns it off.
  • Notepad icon on new Workout Log rows, overridable with --icon.
  • .gitattributes pins *.sh to LF so a Windows checkout cannot break entrypoint.sh.

Testing

  • npm run build, npm run typecheck pass; npm test passes (174 tests).
  • Not yet covered by automated tests: the Docker image build and the /app/data link on a real bucket mount, and live Notion and Telegram calls.

Notes

  • A run that hangs blocks that chat's queue until the process restarts. Runs are capped at 60 turns, so this should be rare.
  • If two dashboard syncs overlap, a tile can briefly appear twice; the next sync clears it.

FrancescoCoding and others added 7 commits November 23, 2026 20:38
A CRLF entrypoint.sh checked out on Windows stops the container from starting.
The container runs from /app but the volume is mounted at /data, so the
scripts and the host were reading and writing two different data folders.
/app/data now links to /data/data and the scripts find data/ from their own
location instead of the current directory.
Reading recent sessions with their sets used to take one call per page.
get-page-blocks takes several page ids at once and query-recent can return
the page bodies along with the rows.
Saves setting the page icon by hand in Notion. --icon overrides it.
sync-dashboard took 9 to 17 seconds inside the agent's turn. The host now
runs it in the background once the reply is sent, whenever the run logged
rows. HOST_DASHBOARD_SYNC=false hands the job back to the agent.
Messages from the same chat now run in order, and ones that pile up behind
a running turn are merged into the next one. Scheduled reminders use the
same queue. Runs longer than about 9 seconds post a short status message
that is edited as work moves on and removed when the reply lands
(PROGRESS_UPDATES=false turns it off).
@FrancescoCoding
FrancescoCoding merged commit 1a5f9e6 into master Nov 23, 2026
1 check passed
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