Repository navigation
feat(agents): session self-service tools - #107471
Conversation
332ed32 to
af570bd
Compare
|
Codex review: needs real behavior proof before merge. Reviewed July 14, 2026, 12:04 PM ET / 16:04 UTC. Summary Reproducibility: not applicable. as a bug reproduction: this PR adds new agent-facing capabilities. The relevant validation question is whether real owner, non-owner, cross-tree, failure-cleanup, and provider-recovery scenarios behave as designed. Review metrics: 3 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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
Maintainer decision needed
Security Review detailsBest possible solution: Land the stacked phases only after rebasing onto the accepted rename head and demonstrating that every new mutation is owner-gated and correctly tree-scoped, visible worktree failures clean up all owned resources, task cancellation cannot cross the caller's tree, and model rollback preserves user-selected settings while recovering only definitive agent-origin failures. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: this PR adds new agent-facing capabilities. The relevant validation question is whether real owner, non-owner, cross-tree, failure-cleanup, and provider-recovery scenarios behave as designed. Is this the best way to solve the issue? Unclear pending maintainer intent. Reusing sessions.create, task_runs, existing depth/sandbox policy, and the current session store is architecturally preferable to parallel infrastructure, but the combined global-group, cancellation, visible-worktree, and automatic-rollback authority surface may need narrowing or splitting. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8251976cf6c7. Label changesLabel changes:
Label justifications:
Evidence reviewedSecurity concerns:
What 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
|
af570bd to
3e771fc
Compare
357643f to
587dad6
Compare
587dad6 to
846cf98
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 846cf989a2
ℹ️ 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".
| for (const task of tasks) { | ||
| if (task.scopeKind !== "session" || visibleTasks.has(task.taskId)) { | ||
| continue; |
There was a problem hiding this comment.
Include cron task rows when building the tree
When the unified list contains real cron runs, this early scopeKind !== "session" filter drops them before checking childSessionKey. Cron creates task ledger rows with ownerKey: "" and scopeKind: "system" in src/cron/service/task-runs.ts, even when the run is tied to a session via childSessionKey, so subagents({action:"list"}) and cancel will omit exactly the cron work the new tool description promises for the caller's session tree. Allow session-related cron/system rows to be admitted by childSessionKey instead of requiring scopeKind === "session" for every runtime.
Useful? React with 👍 / 👎.
846cf98 to
92f9d1b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92f9d1b8eb
ℹ️ 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".
| @@ -48,6 +48,7 @@ export const GATEWAY_CONTROL_PLANE_TOOLS = ["cron", "gateway"] as const; | |||
| */ | |||
| export const GATEWAY_OWNER_ONLY_CORE_TOOLS = [ | |||
| ...GATEWAY_CONTROL_PLANE_TOOLS, | |||
| "sessions", | |||
There was a problem hiding this comment.
Add sessions to the HTTP deny list
Adding sessions only to the owner-only set leaves it available by default to owner-authenticated /tools/invoke requests: shared-secret HTTP auth is treated as owner (src/gateway/http-auth-utils.ts:250-260), and HTTP resolution only default-denies names in DEFAULT_GATEWAY_HTTP_TOOL_DENY before filtering tools (src/gateway/tool-resolution.ts:207-214, src/gateway/tool-resolution.ts:416-422). That means the new tool can patch sessions and mutate the global group catalog over the narrow HTTP automation surface without the explicit gateway.tools.allow opt-in or audit warning used for sessions_spawn/sessions_send; put sessions in the default HTTP deny list as well.
Useful? React with 👍 / 👎.
32ea35c to
4ec7811
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ec78115b9
ℹ️ 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".
| sessionKey: Type.Optional(Type.String({ description: "Target session. Default: current" })), | ||
| label: Type.Optional(Type.String({ description: "Session label" })), | ||
| pinned: Type.Optional(Type.Boolean({ description: "Pin session" })), | ||
| archived: Type.Optional(Type.Boolean({ description: "Archive session" })), | ||
| model: Type.Optional(Type.String({ description: "Model override" })), | ||
| thinkingLevel: Type.Optional(Type.String({ description: "Thinking override" })), | ||
| names: Type.Optional(Type.Array(Type.String(), { description: "Ordered group names" })), | ||
| name: Type.Optional(Type.String({ description: "Group name" })), | ||
| to: Type.Optional(Type.String({ description: "New group name" })), |
There was a problem hiding this comment.
Expose category in the sessions patch tool
When a user asks the new sessions tool to move the current session into a group, the model has no parameter that can send the membership change: this schema only exposes label/pin/archive/model/thinking, while group membership is stored on each session entry's category (src/gateway/session-groups.ts:1-3) and sessions.patch already accepts that field (src/gateway/sessions-patch.ts:384-398). As a result the tool can create, rename, or delete group catalog entries but cannot actually put a session in one of those groups.
Useful? React with 👍 / 👎.
New grouped sessions tool (patch: label/pin/archive/model/thinking; group CRUD; owner-gated; no reset/delete/compact). sessions_spawn gains visible + worktree via sessions.create with admission reservation and abort-confirmed rollback; a started run with no run id is aborted and deleted rather than left orphaned. subagents tool reads the unified task_runs ledger tree-scoped (subagent/acp/media/cron) and cancels detached runs, enforcing the controlScope gate for leaf callers. session_status gains a cost line. Agent-origin model patches record a fallback marker; runs failing on auth/billing/model_not_found revert to the last working model (transient errors never revert), and an independent thinkingLevel change realigns the marker so revert cannot clobber it. Refs #107237
4ec7811 to
92128ce
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92128cece1
ℹ️ 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".
| ...(params.label ? { label: params.label } : {}), | ||
| model: resolvedModel, | ||
| task: params.task, | ||
| parentSessionKey: requesterKey, |
There was a problem hiding this comment.
Use live run as visible-session parent
When tools are built for sandboxed/channel turns, agentSessionKey can be the sandbox key while completionOwnerKey is the live runSessionKey (src/agents/openclaw-tools.ts:580-583, populated in src/agents/embedded-agent-runner/run/attempt-tool-base-prepare.ts:234-238). Passing the controller key as parentSessionKey makes sessions.create validate and attach the new dashboard session to the sandbox row (src/gateway/session-create-service.ts:333-343); if that row is absent the visible spawn fails as an unknown parent, and if it exists the child is not in the live run's session tree. Use the resolved live/completion requester key for the visible session parent.
Useful? React with 👍 / 👎.
What Problem This Solves
Phase 1 of #107237 (stacked on #107320). Agents cannot manage their own sessions: no rename/pin/archive, no group management, no way to start a user-visible session (with or without a worktree), no unified view of background work, no cost visibility, and a bad self-selected model switch permanently nerfs the session.
Why This Change Was Made
sessionstool (owner-gated):patch(label/pinned/archived/model/thinkingLevel, own session tree only) + globalgroup_list/group_set/group_rename/group_delete. Reset/delete/compact are deliberately absent from the action enum.sessions_spawngainsvisible: true(+worktree/worktreeName/worktreeBaseRef): routes throughsessions.create(the task-suggestion-accept precedent) so the child is a real dashboard session with a session-owned worktree; completion-announce contract kept via the subagent registry; admission reservation enforces max-children; failed starts roll back with abort-confirmed deletion only. Depth/target-policy/sandbox rules reused from the hidden path;cwd/execNodestay unexposed (admin-scope boundary).subagentstool now reads the unifiedtask_runsledger, tree-scoped: subagent, acp, media-generation, and cron runs in one list, pluscancelfor tasks inside the caller's tree.session_statusgains a timeout-guarded cost/tokens line from the session-cost cache (cost partialmarker when incomplete; omitted when cold).sessionstool record a fallback marker (in-process gateway origin only — external transports cannot claim it). A following run failing with auth/billing/model_not_found reverts to the previous working model and leaves a system note. Transient provider states (rate_limit/overloaded/timeout/server_error) never revert. Marker clears on first success; user-initiated switches are untouched.User Impact
Agents can retitle/pin/archive/group sessions, switch their own session model safely, start visible worktree sessions the user can watch, see and cancel all background work in their tree, and report session cost in status.
Evidence
node scripts/run-vitest.mjs): sessions tool, sessions-spawn (visible+worktree matrix incl. rollback/announce/depth/sandbox), subagents ledger view + cancel, status cost line, sessions.patch marker atomicity, cross-agent depth — 181 tests.