feat(sessions): expose label in sessions.list and support label lookup in sessions_send#570
Merged
Merged
Conversation
de99d77 to
09cbca7
Compare
09cbca7 to
7057fc8
Compare
…p in sessions_send
- Add `label` field to session entries and expose it in `sessions.list`
- Display label column in the web UI sessions table
- Support `label` parameter in `sessions_send` for lookup by label instead of sessionKey
- `sessions.patch`: Accept and store `label` field
- `sessions.list`: Return `label` in session entries
- `sessions_spawn`: Pass label through to registry and announce flow
- `sessions_send`: Accept optional `label` param, lookup session by label if sessionKey not provided
- `agent` method: Accept `label` and `spawnedBy` params (stored in session entry)
- Add `label` column to sessions table in web UI
- Changed session store writes to merge with existing entry (`{ ...existing, ...new }`)
to preserve fields like `label` that might be set separately
We attempted to implement label persistence "properly" by passing the label
through the `agent` call and storing it during session initialization. However,
the auto-reply flow has multiple write points that overwrite the session entry,
and making all of them merge-aware proved unreliable.
The working solution patches the label in the `finally` block of
`runSubagentAnnounceFlow`, after all other session writes complete.
This is a workaround but robust - the patch happens at the very end,
just before potential cleanup.
A future refactor could make session writes consistently merge-based,
which would allow the cleaner approach of setting label at spawn time.
```typescript
// Spawn with label
sessions_spawn({ task: "...", label: "my-worker" })
// Later, find by label
sessions_send({ label: "my-worker", message: "continue..." })
// Or use sessions_list to see labels
sessions_list() // includes label field in response
```
- Test finding session by label - Test error when label not found - Test error when neither sessionKey nor label provided
0529ceb to
c4c0f13
Compare
Contributor
steipete
added a commit
that referenced
this pull request
Jan 9, 2026
Contributor
|
Follow-up landed on main after merge.
Adds sessions.list label filtering, enforces label max length + uniqueness, and unifies sessions.patch normalization (incl. elevated/off semantics). Thanks @azade-c! |
steipete
added a commit
that referenced
this pull request
Jan 9, 2026
lovewanwan
pushed a commit
to lovewanwan/openclaw
that referenced
this pull request
Apr 28, 2026
lovewanwan
pushed a commit
to lovewanwan/openclaw
that referenced
this pull request
Apr 28, 2026
lovewanwan
pushed a commit
to lovewanwan/openclaw
that referenced
this pull request
Apr 28, 2026
lovewanwan
pushed a commit
to lovewanwan/openclaw
that referenced
this pull request
Apr 28, 2026
feat(sessions): expose label in sessions.list and support label lookup in sessions_send
lovewanwan
pushed a commit
to lovewanwan/openclaw
that referenced
this pull request
Apr 28, 2026
lovewanwan
pushed a commit
to lovewanwan/openclaw
that referenced
this pull request
Apr 28, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
May 9, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
May 9, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
May 9, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
May 9, 2026
feat(sessions): expose label in sessions.list and support label lookup in sessions_send
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
May 9, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
May 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds proper support for the
labelparameter insessions_spawn:sessions.listresponsesessions_sendto find sessions by labelMotivation
The
labelparameter existed insessions_spawnbut was never actually persisted - it was a "phantom parameter". This PR makes it functional, enabling users to:sessions_sendChanges
Core Feature
sessions.patch: Accept and storelabelfieldsessions.list: Returnlabelin session entriessessions_spawn: Pass label through registry → announce flow → patchsessions_send: New optionallabelparam for lookup (alternative tosessionKey)UI
Safety Improvement
{ ...existing, ...new })labelduring concurrent writesArchitecture Note
We initially attempted to persist the label "properly" by passing it through the
agentcall and storing it during session initialization. However, the auto-reply flow has multiple session write points that overwrite entries, and making them all merge-aware proved unreliable.Working solution: Patch the label in the
finallyblock ofrunSubagentAnnounceFlow, after all other writes complete. This is a workaround but robust.A future refactor could make all session writes consistently merge-based, enabling the cleaner approach.
Usage
Files Changed (20)
Core:
src/config/sessions.ts- Add label to SessionEntry typesrc/gateway/protocol/schema.ts- Add label to schemassrc/gateway/server-methods/sessions.ts- Handle label in patchsrc/gateway/session-utils.ts- Return label in list mappingsrc/agents/tools/sessions-spawn-tool.ts- Pass label to registrysrc/agents/subagent-registry.ts- Store and forward labelsrc/agents/subagent-announce.ts- Patch label in finallysrc/agents/tools/sessions-send-tool.ts- Label lookup supportSafety (merge writes):
src/auto-reply/reply/session.tssrc/auto-reply/reply/agent-runner.tssrc/auto-reply/reply/directive-handling.tssrc/auto-reply/reply/model-selection.tssrc/auto-reply/reply/session-updates.tsUI:
ui/src/ui/types.tsui/src/ui/views/sessions.ts