feat: prepend time-gap notice to user message when >5 min elapsed #10

Merged
wylab merged 4 commits from feature/time-gap-injection into main 2026-02-19 01:13:11 +01:00
Owner

Summary

  • Adds time-gap awareness to _process_message in nanobot/agent/loop.py
  • When >5 minutes have passed since the last user message in a session, prepends [SYSTEM ANNOUNCEMENT: X minutes/hours/days have elapsed since last user message] to the current message content
  • Keeps the LLM aware of real time elapsed between conversation turns

Implementation Details

  • Walks session.messages in reverse to find the last user message timestamp
  • Uses datetime.fromisoformat() to parse the stored ISO timestamps
  • Threshold: 300s (5 min) → formats as minutes, hours, or days
  • Malformed timestamps silently skipped (try/except)
  • Note: session.add_message("user", ...) runs after build_messages, so the reversed walk finds the previous user message — no off-by-one issue
  • Only affects _process_message; _process_system_message (subagent announces) is unchanged

Test plan

  • Send two messages with >5 min gap — second message should log with [SYSTEM ANNOUNCEMENT: X minutes have elapsed...] prefix
  • Send two messages with <5 min gap — no prefix injected
  • Verify new session (no prior messages) — no prefix injected

🤖 Generated with Claude Code

## Summary - Adds time-gap awareness to `_process_message` in `nanobot/agent/loop.py` - When >5 minutes have passed since the last user message in a session, prepends `[SYSTEM ANNOUNCEMENT: X minutes/hours/days have elapsed since last user message]` to the current message content - Keeps the LLM aware of real time elapsed between conversation turns ## Implementation Details - Walks `session.messages` in reverse to find the last user message timestamp - Uses `datetime.fromisoformat()` to parse the stored ISO timestamps - Threshold: 300s (5 min) → formats as minutes, hours, or days - Malformed timestamps silently skipped (try/except) - Note: `session.add_message("user", ...)` runs **after** `build_messages`, so the reversed walk finds the *previous* user message — no off-by-one issue - Only affects `_process_message`; `_process_system_message` (subagent announces) is unchanged ## Test plan - [ ] Send two messages with >5 min gap — second message should log with `[SYSTEM ANNOUNCEMENT: X minutes have elapsed...]` prefix - [ ] Send two messages with <5 min gap — no prefix injected - [ ] Verify new session (no prior messages) — no prefix injected 🤖 Generated with [Claude Code](https://claude.ai/claude-code)
wylab added 1 commit 2026-02-19 00:32:51 +01:00
feat: prepend time-gap notice to user message when >5 min elapsed
Build Nanobot OAuth / cleanup (pull_request) Has been skipped
Build Nanobot OAuth / build (pull_request) Successful in 5m34s
dde242d170
Adds elapsed-time awareness to _process_message. When >5 minutes have
passed since the last user message in a session, prepends a SYSTEM
ANNOUNCEMENT header so the LLM knows time has passed.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
code-server added 1 commit 2026-02-19 00:55:03 +01:00
debug: add time-gap instrumentation logs
Build Nanobot OAuth / cleanup (pull_request) Has been skipped
Build Nanobot OAuth / build (pull_request) Successful in 5m32s
da7f58d3cc
code-server added 1 commit 2026-02-19 01:04:24 +01:00
chore: remove debug logs from time-gap injection
Build Nanobot OAuth / cleanup (pull_request) Has been skipped
Build Nanobot OAuth / build (pull_request) Successful in 6m29s
092248411e
code-server added 1 commit 2026-02-19 01:07:29 +01:00
fix: restore SYSTEM ANNOUNCEMENT prefix, add instruction to take time into account
Build Nanobot OAuth / cleanup (pull_request) Has been skipped
Build Nanobot OAuth / build (pull_request) Successful in 5m48s
4b4ffb8cbc
wylab merged commit bdaa1b35e4 into main 2026-02-19 01:13:11 +01:00
wylab deleted branch feature/time-gap-injection 2026-02-19 01:13:11 +01:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wylab/nanobot#10