Skip to content

feat(opencode): pass sessionID, model, and agent to tool.definition hook#17955

Open
ualtinok wants to merge 1 commit intoanomalyco:devfrom
ualtinok:feat/tool-definition-model-agent
Open

feat(opencode): pass sessionID, model, and agent to tool.definition hook#17955
ualtinok wants to merge 1 commit intoanomalyco:devfrom
ualtinok:feat/tool-definition-model-agent

Conversation

@ualtinok
Copy link
Copy Markdown
Contributor

@ualtinok ualtinok commented Mar 17, 2026

Issue for this PR

Closes #17954
Supersedes #17334 / #17331

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Passes sessionID through the tool registry so tool.definition plugin hooks can adapt tool descriptions based on session context.

Changes:

  1. packages/opencode/src/tool/registry.ts — Refactored ToolRegistry.tools() from positional args (model, agent?) to a single input object { model, sessionID, agent? }. Added SessionID type import.

  2. All call sites updated:

    • session/prompt.ts — threads session.id through
    • tool/batch.ts — threads ctx.sessionID through
    • cli/cmd/debug/agent.ts — creates session before fetching tools, passes session ID to both getAvailableTools and createToolContext
    • server/routes/experimental.ts — requires sessionID query param, validates session exists (404 if missing), added SessionID, NotFoundError, HTTPException imports

How did you verify your code works?

  • Changes are structurally consistent with existing call patterns

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found a related PR:

Related PR Found:

Why it's related: This PR is explicitly mentioned in the current PR's description as being superseded by PR #17955. PR #17331 appears to address a similar concern about requiring session IDs for tool definitions, which is part of the broader refactoring in the current PR.

The current PR (#17955) is the newer implementation that builds upon and supersedes the earlier work in #17331 (and also #17334 as mentioned in the description).

@ualtinok ualtinok force-pushed the feat/tool-definition-model-agent branch 2 times, most recently from 2b43967 to ad05dce Compare April 1, 2026 17:22
@ualtinok ualtinok force-pushed the feat/tool-definition-model-agent branch from e6a43d5 to b890fc5 Compare April 3, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Pass sessionID, model, and agent info to tool.definition hook

1 participant