openhuman
openhuman copied to clipboard
[Agent] Inject device, timezone, and user context into prompts; stop redundant ‘what timezone?’ questions
Summary
Agents should always receive reliable ambient context in the system prompt: device, local date/time with IANA timezone, and authenticated user identity fields (as available), so they do not ask the user for information the app already has. Example: requesting a morning briefing should not elicit “what timezone are you in?” when the desktop app controls the device and can supply that data.
Problem
- User impact: Friction and loss of trust — the model appears unaware of the environment even though the product runs on the user’s machine with a logged-in account.
- Concrete gap (morning briefing): The
morning_briefingbuilt-in agent assembles its system prompt insrc/openhuman/agent/agents/morning_briefing/prompt.rsfrom the archetype +render_user_files,render_tools, andrender_workspaceonly. It does not include the shared## Current Date & Timeblock (DateTimeSectioninsrc/openhuman/agent/prompts/mod.rs, exposed asrender_datetime) or## Runtime(RuntimeSection/render_runtime). So the model has no explicit “now” / timezone / host context in that prompt path. - General pattern: Per-agent
prompt.rsbuilders opt in per section; any agent that omits datetime/runtime is likely to hallucinate a gap and ask the user. - Core vs machine TZ:
DateTimeSectiontoday useschrono::Localin the core process (DateTimeSection::build). Depending on how theopenhumansidecar is launched,Localmay or may not match the user’s OS timezone; the authoritative value for product UX is ideally the desktop app–reported IANA zone (Tauri/JS) plus optional OS locale.
Solution direction
- Standard “ambient” block — Add a small, cache-stable (or per-turn) section, e.g.
## User & device, injected for all or whitelisted built-ins, containing:- Current time: ISO-8601 + human-readable in the user’s timezone
- IANA timezone string (e.g.
America/Los_Angeles) - Device / OS summary (align with
RuntimeSection: host, OS; optionally app version) - User: name / email / id from the authenticated session (
openhuman.auth_get_me/ backend), redacted as needed for logs
- Plumb timezone from the shell — Extend config or session so the ** renderer** (Tauri) reports
Intl/ system timezone to the core on startup or before agent runs, ifchrono::Localis insufficient in CI/edge cases. - Fix morning_briefing prompt assembly — At minimum, call
render_datetimeandrender_runtime(or the new combined section) inmorning_briefing/prompt.rsso the briefing agent sees “now” and environment without tool calls. - Prompt copy — In archetype prompts (e.g.
morning_briefing/prompt.md), one line: “You are given the user’s local time and timezone in the system message — do not ask the user for their timezone unless the system context is missing.” - Audits — Other
omit_identity = trueagents that use customprompt.rs(welcome, orchestrator, etc.): ensure they still get datetime/ambient where appropriate.
Acceptance criteria
- [ ] Morning briefing no longer asks for the user’s timezone in normal operation when the app can supply it; validated manually or with a small prompt fixture test.
- [ ] System prompt for targeted agents includes explicit local time + IANA
timezone+ device OS/host (or references a single## User & deviceblock). - [ ] User/session fields from the backend (non-secret) are available to the prompt layer via
PromptContextor equivalent — not only workspace files. - [ ] Privacy / logs — Document what is embedded; never dump tokens; follow existing redaction rules in
AGENTS.md. - [ ] Tests — Unit test that
morning_briefing’sbuild()output contains the datetime/tz section (or new ambient section) when wired.
Related code
src/openhuman/agent/agents/morning_briefing/prompt.rs— missingrender_datetime/render_runtime/ user ambientsrc/openhuman/agent/prompts/mod.rs—DateTimeSection,RuntimeSection,PromptContextsrc/openhuman/agent/prompts/mod.rs(GLOBAL_STYLE) — where global suffix lives; new section ordering must respect KV-cache notes in file headersapp/src/services/api/userApi.ts—getMefor user fields in UI; parallel path for core may be neededsrc/openhuman/cron/seed.rs— morning briefing cron copy mentions local time; prompt should match
@senamakel picked this — PR #959. scoped to morning_briefing per the issue. noticed the same gap (no datetime/runtime/user block) exists in 14 other custom agent prompt builders — kept it out for review surface, happy to do a follow-up if you want it.