Skip to content

Agents: add machine-readable session status time#51683

Open
08820048 wants to merge 1 commit intoopenclaw:mainfrom
08820048:fix-session-status-machine-time-10841
Open

Agents: add machine-readable session status time#51683
08820048 wants to merge 1 commit intoopenclaw:mainfrom
08820048:fix-session-status-machine-time-10841

Conversation

@08820048
Copy link
Copy Markdown

Summary

  • Problem: session_status only exposed human-readable local time, so reminder scheduling could not reliably compute exact timestamps.
  • Why it matters: cron/reminder flows need machine-readable current time to convert requests like "in 30 minutes" into exact ISO-8601 schedules.
  • What changed: added a local ISO timestamp formatter, appended local ISO + UTC time to the session_status time line, and added a regression test.
  • What did NOT change (scope boundary): no system prompt injection changes, no cron scheduler behavior changes, and no auth/security surface changes.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

session_status now includes machine-readable current time alongside the readable local time, for example local ISO plus UTC.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS 26.4
  • Runtime/container: local zsh shell
  • Model/provider: N/A
  • Integration/channel (if any): agent session_status
  • Relevant config (redacted): agents.defaults.userTimezone=America/Los_Angeles, agents.defaults.timeFormat=12

Steps

  1. Call session_status for a session with a configured user timezone.
  2. Inspect the 🕒 Time: line in the returned status card.
  3. Confirm it includes readable local time plus local ISO time and UTC time.

Expected

  • session_status returns exact machine-readable current time that an agent can use for reminder scheduling.

Actual

  • Before: only human-readable local time.
  • After: human-readable local time plus local ISO ... and UTC ....

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: checked the formatter output for 2026-02-08T03:15:00Z and confirmed it renders Saturday, February 7th, 2026 — 7:15 PM, 2026-02-07T19:15:00-08:00, and 2026-02-08T03:15:00Z.
  • Edge cases checked: local offset formatting for a non-UTC timezone; UTC seconds formatting.
  • What you did not verify: in this Codex terminal environment, pnpm test -- src/agents/openclaw-tools.session-status.test.ts and raw vitest run did not exit cleanly, so I did not get a clean local Vitest completion signal even though the regression test was added.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit 9bc10cd21
  • Files/config to restore: src/agents/date-time.ts, src/agents/tools/session-status-tool.ts, src/agents/openclaw-tools.session-status.test.ts
  • Known bad symptoms reviewers should watch for: malformed time line formatting or missing timezone offset in session_status

Risks and Mitigations

  • Risk: Intl.DateTimeFormat(..., { timeZoneName: "longOffset" }) could behave differently on some runtimes.
    • Mitigation: formatter falls back to existing human-readable time when local ISO formatting fails, and UTC output remains present.

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: S labels Mar 21, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 21, 2026

Greptile Summary

This PR appends machine-readable local ISO and UTC timestamps to the session_status time line, enabling cron/reminder flows to compute exact schedules from phrases like "in 30 minutes." The implementation is clean and well-contained.

  • src/agents/date-time.ts — New formatUserLocalIsoTimestamp helper uses Intl.DateTimeFormat with timeZoneName: "longOffset" to produce an ISO-8601+offset string. The try/catch + regex guard (/^[+-]\d{2}:\d{2}$/) correctly handle runtime failures and malformed offsets; tested edge cases (UTC, half-hour offsets like IST +05:30) all resolve correctly.
  • src/agents/tools/session-status-tool.ts — The new segments are assembled with .filter(Boolean) so the local-ISO portion is silently omitted when formatUserLocalIsoTimestamp returns undefined, while the UTC segment (non-nullable via formatUtcTimestamp) is always present. Both the human-readable and fallback time-zone lines are updated consistently.
  • src/agents/openclaw-tools.session-status.test.ts — A regression test pins the clock to 2026-02-08T03:15:00Z with America/Los_Angeles and verifies all three expected substrings. The top-level afterEach(() => vi.useRealTimers()) cleanup is harmless — no other test uses fake timers — though it would be marginally cleaner scoped inside the describe block.

Confidence Score: 5/5

  • This PR is safe to merge — additive-only change with proper fallbacks and a targeted regression test.
  • The change is small and strictly additive: a new pure formatter plus two extra string segments in the status card. The formatter returns undefined on any failure and the downstream code handles that gracefully. No auth, security, or storage surfaces are touched. The regression test covers the primary path, and the existing test suite is unaffected. The only note is a minor style nit (top-level afterEach placement), which is non-blocking.
  • No files require special attention.

Last reviewed commit: "Agents: add machine-..."

@08820048 08820048 force-pushed the fix-session-status-machine-time-10841 branch from 9bc10cd to cd8c2da Compare March 21, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reminders set for wrong times because agent doesn't know current time

1 participant