feat(tool): allow human-readable slugs as task_id#32122
Open
rafaelchavesfreitas wants to merge 5 commits into
Open
feat(tool): allow human-readable slugs as task_id#32122rafaelchavesfreitas wants to merge 5 commits into
rafaelchavesfreitas wants to merge 5 commits into
Conversation
The task tool now accepts human-readable slugs (e.g. "explore-auth") as task_id, making it easy for LLMs to create and resume named task sessions without carrying opaque ses_ IDs across turns. If the slug hasn't been used in the current root session, a new session is created with a derived ID (ses_<hash>_<slug>). If it already exists, the session is resumed with full context. Closes anomalyco#32118
This was referenced Jun 13, 2026
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 25, 2026
Accept a human-readable slug as the task tool's task_id: it is resolved to a
deterministic session ID derived from the root session, so passing the same
slug resumes the named task and a new slug creates one. Full "ses_..." IDs
still resume directly. Adds Session.create({ id }) and Session.root().
Ported from anomalyco#32122 (adapted for the Effect layer).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 25, 2026
Add an experimental `mcp_lazy` config flag. When enabled, MCP tools are no longer loaded into the model context automatically; instead a new mcp_search tool (list/search/describe/call) discovers and invokes MCP tools on demand, and the prompt loop advertises connected MCP servers in the system prompt. mcp_search is only registered when the flag is set and MCP is available. Ported from anomalyco#12520 (adapted for the Effect layer: the server advert is built inline in the prompt loop rather than via a SystemPrompt service method, and Config is provided at the SessionTools.resolve call site). The TUI "Lazy" status badge from the original PR is omitted (its dialog moved packages and the badge is cosmetic). SDK regeneration also includes the session-create `id` field from anomalyco#32122. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 25, 2026
Add an experimental subagent-interrupt capability (behind OPENCODE_EXPERIMENTAL_SUBAGENT_INTERRUPT): an Interrupt service with pending/terminal state, task_steer/task_cancel/task_abort tools (gated by a new `interrupt` permission), a POST /session/:id/interrupt endpoint, and a turn-boundary consume in the prompt loop that injects an escaped steer/cancel frame plus a visible transcript marker. Cancel records a terminal reason and force-breaks after a grace window; abort writes a marker, records the terminal, and cancels the BackgroundJob immediately. The TUI gains an esc-with-reason flow, footer button, and distinct interrupt markers. Ported from anomalyco#32425 (adapted for the Effect layer; merged with the prior task.ts/registry.ts/prompt.ts changes from anomalyco#29447/anomalyco#32122/anomalyco#12520/anomalyco#32192/anomalyco#19961). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 25, 2026
The task tool's task_id description changed in the slug-resume port (anomalyco#32122); update the JSON Schema wire-shape snapshot to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 25, 2026
Accept a human-readable slug as the task tool's task_id: it is resolved to a
deterministic session ID derived from the root session, so passing the same
slug resumes the named task and a new slug creates one. Full "ses_..." IDs
still resume directly. Adds Session.create({ id }) and Session.root().
Ported from anomalyco#32122 (adapted for the Effect layer).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 25, 2026
Add an experimental `mcp_lazy` config flag. When enabled, MCP tools are no longer loaded into the model context automatically; instead a new mcp_search tool (list/search/describe/call) discovers and invokes MCP tools on demand, and the prompt loop advertises connected MCP servers in the system prompt. mcp_search is only registered when the flag is set and MCP is available. Ported from anomalyco#12520 (adapted for the Effect layer: the server advert is built inline in the prompt loop rather than via a SystemPrompt service method, and Config is provided at the SessionTools.resolve call site). The TUI "Lazy" status badge from the original PR is omitted (its dialog moved packages and the badge is cosmetic). SDK regeneration also includes the session-create `id` field from anomalyco#32122. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 25, 2026
Add an experimental subagent-interrupt capability (behind OPENCODE_EXPERIMENTAL_SUBAGENT_INTERRUPT): an Interrupt service with pending/terminal state, task_steer/task_cancel/task_abort tools (gated by a new `interrupt` permission), a POST /session/:id/interrupt endpoint, and a turn-boundary consume in the prompt loop that injects an escaped steer/cancel frame plus a visible transcript marker. Cancel records a terminal reason and force-breaks after a grace window; abort writes a marker, records the terminal, and cancels the BackgroundJob immediately. The TUI gains an esc-with-reason flow, footer button, and distinct interrupt markers. Ported from anomalyco#32425 (adapted for the Effect layer; merged with the prior task.ts/registry.ts/prompt.ts changes from anomalyco#29447/anomalyco#32122/anomalyco#12520/anomalyco#32192/anomalyco#19961). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 25, 2026
The task tool's task_id description changed in the slug-resume port (anomalyco#32122); update the JSON Schema wire-shape snapshot to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 30, 2026
Accept a human-readable slug as the task tool's task_id: it is resolved to a
deterministic session ID derived from the root session, so passing the same
slug resumes the named task and a new slug creates one. Full "ses_..." IDs
still resume directly. Adds Session.create({ id }) and Session.root().
Ported from anomalyco#32122 (adapted for the Effect layer).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 30, 2026
Add an experimental `mcp_lazy` config flag. When enabled, MCP tools are no longer loaded into the model context automatically; instead a new mcp_search tool (list/search/describe/call) discovers and invokes MCP tools on demand, and the prompt loop advertises connected MCP servers in the system prompt. mcp_search is only registered when the flag is set and MCP is available. Ported from anomalyco#12520 (adapted for the Effect layer: the server advert is built inline in the prompt loop rather than via a SystemPrompt service method, and Config is provided at the SessionTools.resolve call site). The TUI "Lazy" status badge from the original PR is omitted (its dialog moved packages and the badge is cosmetic). SDK regeneration also includes the session-create `id` field from anomalyco#32122. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 30, 2026
Add an experimental subagent-interrupt capability (behind OPENCODE_EXPERIMENTAL_SUBAGENT_INTERRUPT): an Interrupt service with pending/terminal state, task_steer/task_cancel/task_abort tools (gated by a new `interrupt` permission), a POST /session/:id/interrupt endpoint, and a turn-boundary consume in the prompt loop that injects an escaped steer/cancel frame plus a visible transcript marker. Cancel records a terminal reason and force-breaks after a grace window; abort writes a marker, records the terminal, and cancels the BackgroundJob immediately. The TUI gains an esc-with-reason flow, footer button, and distinct interrupt markers. Ported from anomalyco#32425 (adapted for the Effect layer; merged with the prior task.ts/registry.ts/prompt.ts changes from anomalyco#29447/anomalyco#32122/anomalyco#12520/anomalyco#32192/anomalyco#19961). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable
added a commit
to randomvariable/opencode
that referenced
this pull request
Jun 30, 2026
The task tool's task_id description changed in the slug-resume port (anomalyco#32122); update the JSON Schema wire-shape snapshot to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3 tasks
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.
Issue for this PR
Closes #32118
Type of change
What does this PR do?
The Task tool's
task_idparameter now accepts human-readable slugs (e.g."explore-auth") in addition to opaqueses_session IDs.The problem: Task tool outputs IDs like
ses_14209ee2affeovRO3QEIAheNCH. These are designed for DB sort order, not for LLM recall. When an LLM needs to resume a subagent, it must reproduce this string exactly across turns — which it routinely fails at, creating new sessions instead and losing all prior context.How it works: When
task_iddoesn't start withses_, it's treated as a slug. The tool derives a deterministic session ID by combining a 4-char hash of the root session ID with the slug:ses_a3f2_explore-auth. It then looks up that ID — if it exists, the session is resumed; if not, a new one is created with that ID. Whentask_idstarts withses_, the original lookup-by-ID behavior is unchanged.The slug is scoped to the root session (the top-level session without a parent). A new
Session.root()method walks theparentIDchain to find it. This means subagents sharing the same root session can reference each other's named tasks — enabling cross-agent collaboration within a conversation. Subagents in different root sessions are isolated.Changes:
session.ts: Addedroot()method (traverses parentID chain to root session), added optionalidparameter tocreate()/CreateInput/Interfaceso a session can be created with a specific IDtask.ts: AddedisSlug()andderiveSlugSessionID()helpers, modified the session lookup/creation flow to detect slugs, derive IDs, and pass them through on creationtask.txt: Updated the task tool description that LLMs read, documenting the slug supportHow did you verify your code works?
bun typecheckpasses inpackages/opencodeses_...task_id values follow the same code path (the slug branch only activates whentask_iddoesn't start withses_)Session.root()loop uses the samewhile+letpattern as the existingfindMessagemethod in the same fileScreenshots / recordings
N/A — no UI changes.
Checklist