feat: add core session goals#87469
Conversation
|
Codex review: found issues before merge. Reviewed May 29, 2026, 4:24 PM ET / 20:24 UTC. Summary Reproducibility: yes. Source inspection gives a high-confidence path: selected-global local runs store Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land only after local selected-global events carry Do we have a high-confidence way to reproduce the issue? Yes. Source inspection gives a high-confidence path: selected-global local runs store Is this the best way to solve the issue? No. The core goal design may be acceptable, but the current branch needs the local event scope and live goal-state persistence fixes before it is the narrow maintainable solution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against eb7e237151e7. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
This comment has been minimized.
This comment has been minimized.
|
ClawSweeper PR egg: 🔥 warming; proof passed, review follow-up or readiness checks remain. Hatch with Rules and detailsHatchability:
About:
|
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09da62fac6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const snapshot = await getSessionGoal({ | ||
| ...resolveGoalSessionScope(options), | ||
| persist: false, |
There was a problem hiding this comment.
Persist goal accounting for get_goal reads
When a goal is created before the session has a fresh token snapshot, this read-only path calls getSessionGoal with persist: false, which also forces adoptFreshBaseline: false. In that scenario, later get_goal calls keep returning the stale tokenStartFresh: false state with tokensUsed unchanged, so token budgets never become effective for the model unless the user happens to run /goal manually; this contradicts the intended “adopt the next fresh snapshot” behavior for goals created early in a session.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f3835efaa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const tokensUsed = | ||
| totalTokens === undefined || shouldAdoptFreshStart || shouldHoldStaleStart | ||
| ? goal.tokensUsed | ||
| : Math.max(goal.tokensUsed, Math.max(0, totalTokens - tokenStart)); |
There was a problem hiding this comment.
Freeze token usage after goal completion
When a goal has already been marked complete, later /goal or get_goal reads still pass through this accounting path and recompute tokensUsed from the current session total. In any session that continues after completing a goal without immediately clearing it, the completed goal's usage keeps growing with unrelated follow-up turns, so the final usage shown for the achieved objective is no longer the usage at completion even though complete is treated as terminal elsewhere.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0df5647081
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const resetsBudgetWindow = | ||
| options.status === "active" && | ||
| (accounted.status === "budget_limited" || accounted.status === "usage_limited"); | ||
| const freshTokenStart = resetsBudgetWindow ? resolveEntryFreshTotalTokens(entry) : undefined; |
There was a problem hiding this comment.
Reset over-budget inactive goals on resume
When a paused or blocked goal with a token budget accumulates enough fresh session tokens to meet the budget, accountGoalUsage updates tokensUsed but keeps the inactive status, so this check does not reset the budget window on /goal resume. The command returns an active goal whose tokensUsed >= tokenBudget, and the next status read or usage persist immediately flips it back to budget_limited, making resume effectively a no-op for paused/blocked goals that crossed the budget while inactive.
Useful? React with 👍 / 👎.
552c658 to
0a12400
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a12400fff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| async runGoalCommand(opts: Parameters<NonNullable<TuiBackend["runGoalCommand"]>>[0]) { | ||
| const { canonicalKey, storePath, entry } = loadSessionEntry(opts.sessionKey); |
There was a problem hiding this comment.
Route local global goals to the selected agent
In local TUI mode this loads /goal state with only the literal session key, so when the current session is global and the operator has selected a non-default agent, loadSessionEntry() falls back to the default agent store rather than the selected agent's global store. The gateway resolver already requires an explicit agentId for global/unknown keys, so /goal start/status/clear from openclaw tui --local can create or read the goal under main while the footer and session list are scoped to the selected agent.
Useful? React with 👍 / 👎.
e8301e9 to
1293575
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f2397255fc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const goal = await updateSessionGoalStatus({ | ||
| ...resolveGoalSessionScope(options), | ||
| status: status as (typeof MODEL_UPDATABLE_SESSION_GOAL_STATUSES)[number], | ||
| ...(note ? { note } : {}), | ||
| }); |
There was a problem hiding this comment.
Preserve update_goal results through turn persistence
When update_goal runs during an agent turn that already loaded a goal, this writes the new status directly to the session store but never refreshes the agent command's in-memory session entry. Later turn persistence merges the stale working-copy entry back into the store, and because that entry still contains the old goal object, it can overwrite the completed/blocked status before the run finishes. This affects normal model-driven update_goal completion/blocking; update the live session entry/store after this write or avoid carrying stale goal fields into later persistence.
Useful? React with 👍 / 👎.
Mantis Telegram Desktop ProofSummary: Mantis captured native Telegram Desktop before/after GIFs showing the new /goal replies in chat.
Motion-trimmed clips: Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-87469/run-26655798776-1/index.json |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28dc756c23
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const queuedRunReadiness = createQueuedRunReadiness(); | ||
| this.runs.set(runId, { | ||
| sessionKey: opts.sessionKey, | ||
| agentId: opts.agentId, |
There was a problem hiding this comment.
Propagate agentId on local global chat events
When openclaw tui --local is in global scope with a non-default selected agent, this newly stores the run's agentId, but the local backend's emitChatDelta/emitChatFinal/emitChatAborted/chat.side_result payloads still only send sessionKey: "global". src/tui/tui-event-handlers.ts now rejects global events without agentId unless the selected agent is the default, so /agent work followed by a global local send will drop the stream/final/abort events and leave the TUI without the response even though the run is scoped and executing.
Useful? React with 👍 / 👎.
|
Verification for head Behavior addressed:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6006871d80
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const p = params; | ||
| const key = requireSessionKey(p.key, respond); |
There was a problem hiding this comment.
Scope sessions.describe to the requested agent
When a client is viewing the literal global session for a non-default agent, this handler still has no agentId path and the lookup below calls resolveGatewaySessionTargetFromKey(key, cfg) without an override, so sessions.describe describes the default agent's global row while the newly updated list/history/send paths use the selected agent. Add agentId to the describe params and pass it through the same global-agent resolution used by the other session methods.
Useful? React with 👍 / 👎.
|
Verification after the final fixup on current PR head Behavior addressed: Evidence after fix: Testbox passed 4 Vitest shards / 373 tests with exitCode=0. Autoreview: |
|
Verification after final rebase/fixup on current PR head Behavior addressed: Evidence after fix: Testbox passed 4 Vitest shards / 374 tests with exitCode=0. Autoreview: |




Summary
SessionEntry, exposesget_goal/create_goal/update_goalmodel tools, and adds native/text/goalcontrols.Verification
Behavior addressed: Core-owned thread/session goals with model tools,
/goalcontrols, TUI footer status, and dedicated docs, replacing plugin-owned PR #85723.Real environment tested: Local OpenClaw checkout.
Exact steps or command run after this patch:
pnpm exec oxfmt --check ...on touched TS/docs filesnode scripts/run-oxlint.mjs ...on touched TS filespnpm docs:listpnpm docs:check-mdxpnpm format:docs:checkpnpm docs:check-links -- docs/tools/goal.md docs/tools/slash-commands.md docs/web/tui.md docs/cli/tui.md docs/tools/index.mdgit diff --checkpnpm exec tsx -e ...direct goal lifecycle, formatter, stale-baseline, budget-resume, and TUI session-refresh smokes/Users/steipete/Projects/agent-skills/skills/autoreview/scripts/autoreview --mode localEvidence after fix: Formatting, oxlint, docs index, docs MDX, docs formatting, docs links, whitespace, direct TS smokes, and final local autoreview passed. Final autoreview reported no accepted/actionable findings.
Observed result after fix: Goals persist in core session state; model tools can read/create/complete/block goals;
/goalcan start, show, pause, resume, complete, block, and clear goals; blocked goals can be resumed; budget-limited goals resume with a fresh budget window; stale token baselines are not overcounted; TUI session rows carry goal state and the footer shows compact goal status.What was not tested: Vitest wrapper did not complete in this checkout; it hung without test output and was stopped. Earlier broad
tsgowas blocked on existing unrelatedsrc/config/io.tsunique-symbol errors.