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
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented Apr 28, 2026

Codex review: needs changes before merge.

Summary
The PR adds a local ISO timestamp helper, appends local ISO plus UTC time to session_status output, and adds pinned-clock regression coverage.

Reproducibility: yes. at source level: docs direct agents to session_status for current time, but current main calls buildStatusText without any timeLine, and the shared status params/builder cannot forward one to the renderer.

Next step before merge
A small automated repair can refresh this useful PR against the current shared status runtime and add the missing changelog without product or security judgment.

Security
Cleared: The PR only changes local date formatting, status-card text assembly, and tests; it adds no dependencies, network calls, permissions, secret handling, CI, or package execution paths.

Review findings

  • [P2] Thread the time line through shared status text — src/agents/tools/session-status-tool.ts:526
  • [P2] Make the session_status test observe the time line — src/agents/openclaw-tools.session-status.test.ts:366-368
  • [P2] Match the current readable time separator — src/agents/openclaw-tools.session-status.test.ts:366-368
Review details

Best possible solution:

Land a current-main patch that threads local ISO-with-offset plus UTC time through the shared status text contract, covers both session_status and shared status rendering, and records the user-facing fix in the changelog.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: docs direct agents to session_status for current time, but current main calls buildStatusText without any timeLine, and the shared status params/builder cannot forward one to the renderer.

Is this the best way to solve the issue?

No, not as-is. The direction is narrow and maintainable, but the PR must be refreshed for the current shared status contract, current formatter output, and changelog policy before it is the best fix.

Full review comments:

  • [P2] Thread the time line through shared status text — src/agents/tools/session-status-tool.ts:526
    Against current main, BuildStatusTextParams has no timeLine field and buildStatusText never forwards one to buildStatusMessage. Adding the timestamp only at this tool call site is either type-invalid or dropped by the shared builder, so the new line will not reliably render until the shared status contract is updated.
    Confidence: 0.95
  • [P2] Make the session_status test observe the time line — src/agents/openclaw-tools.session-status.test.ts:366-368
    This test file mocks ./tools/session-status.runtime.js, and the current mock returns only OpenClaw, the model line, and the task line. The new details.statusText assertions will fail unless the mock accepts/returns the new timeLine or the test verifies the shared status builder path directly.
    Confidence: 0.92
  • [P2] Match the current readable time separator — src/agents/openclaw-tools.session-status.test.ts:366-368
    Current formatUserTime renders Saturday, February 7th, 2026 - 7:15 PM, but the new assertion expects the older em dash form. Once the time line is actually included, this assertion will fail before it verifies the local ISO and UTC suffixes.
    Confidence: 0.96
  • [P3] Add the required changelog entry — src/agents/tools/session-status-tool.ts:526
    This changes user-visible session_status output for a bug fix, but the PR does not update CHANGELOG.md. OpenClaw policy requires a changelog entry before merging user-facing fixes.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.93

Acceptance criteria:

  • pnpm test src/agents/openclaw-tools.session-status.test.ts
  • pnpm test src/auto-reply/reply/commands-status.test.ts
  • pnpm exec oxfmt --check --threads=1 src/agents/date-time.ts src/agents/tools/session-status-tool.ts src/agents/openclaw-tools.session-status.test.ts src/status/status-text.ts src/status/status-text.types.ts src/status/status-message.ts CHANGELOG.md
  • pnpm check:changed

What I checked:

  • Current session_status call path has no time line: createSessionStatusTool resolves the target session and calls buildStatusText without constructing or passing a timestamp line on current main. (src/agents/tools/session-status-tool.ts:629, 7c0f5463a564)
  • Shared status params cannot carry timeLine: BuildStatusTextParams has no timeLine field, so the PR's proposed call-site-only addition is stale against the current shared status contract. (src/status/status-text.types.ts:11, 7c0f5463a564)
  • Shared status builder does not forward timeLine: buildStatusText calls buildStatusMessage without timeLine, even though the renderer supports it, so the requested line must be threaded through the shared builder. (src/status/status-text.ts:333, 7c0f5463a564)
  • Renderer supports optional timeLine: StatusArgs already has timeLine?: string, and the output array includes args.timeLine, confirming the missing seam is in the shared status-text layer. (src/status/status-message.ts:99, 7c0f5463a564)
  • Docs point agents to session_status for current time: The Date & Time docs say agents should use session_status for current time and that the status card includes a timestamp line. Public docs: docs/date-time.md. (docs/date-time.md:75, 7c0f5463a564)
  • Current formatter separator differs from PR assertion: Current formatUserTime returns the date/time separator as -, while the PR's new assertion expects an em dash string from older output. (src/agents/date-time.ts:189, 7c0f5463a564)

Likely related people:

  • dutifulbob: Co-authored the fix: extract shared session status runtime #65807 squash commit that moved session status text into src/status and made this PR's current seam the shared status contract. (role: shared status runtime owner; confidence: high; commits: 380de88a61de; files: src/status/status-text.ts, src/agents/tools/session-status-tool.ts, src/agents/openclaw-tools.session-status.test.ts)
  • vincentkoc: Recent history includes fix(status): align session_status with /status, and current blame in the shallow checkout points the status/session_status area through a recent Vincent Koc-authored grafted commit. (role: recent session_status/status maintainer; confidence: medium; commits: 11318ef9b949; files: src/status/status-text.ts, src/agents/tools/session-status-tool.ts, src/agents/openclaw-tools.session-status.test.ts)
  • jriff: Authored feat: append UTC time alongside local time in shared Current time lines #32423, which appended a machine-readable UTC suffix to shared cron-style current-time prompt lines related to the same reminder/time-disambiguation problem. (role: related current-time behavior contributor; confidence: medium; commits: aad372e15fb9; files: src/agents/current-time.ts, src/auto-reply/reply/session-reset-prompt.test.ts, CHANGELOG.md)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 7c0f5463a564.

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