feat: agent tool variants, server tools, multi tool-result helper#1
Open
rimdoo wants to merge 1 commit into
Open
feat: agent tool variants, server tools, multi tool-result helper#1rimdoo wants to merge 1 commit into
rimdoo wants to merge 1 commit into
Conversation
Open `AgentTool.Other` constructor to public — the documented escape hatch for unmodeled tool variants was unreachable from outside the module ([cite: prior `internal constructor`]). New typed variants for the common cases: - `AgentTool.Toolset20260401Subset(enabled: Set<DefaultTool>)` — subset of the bundled toolset via `default_config.enabled = false` + per-tool `addConfig`. - `AgentTool.McpToolset(serverName, enabled?)` — reference a registered MCP server, optionally whitelisting tool names. - `AgentTool.CustomTool(name, description, rawInputSchema)` — client-side tools; raw schema type retained so nested JSON Schema stays expressible. Adjacent: - `McpUrlServer(name, url)` + `createAgent(mcpServers = ...)` register remote MCP servers at agent creation. - `createSession(vaultIds = ...)` attaches vault credentials for MCP auth. - `SessionStreamEvent.AgentCustomToolUse(id, name, inputJson)` — previously absorbed by `SessionStreamEvent.Other`. - `Message.toolResults(...)` bundles multiple `tool_result` blocks into one user message (required when the assistant emits >1 `tool_use` per turn). - `ServerTool` sealed (`WebSearch` / `WebFetch`) + `serverTools` parameter on `createMessage` / `streamMessage`. Mixes freely with client-side `tools`. 134 unit tests (37 + 7 + 7 + 81 + 2 new MappersTest, +5 new ClientApiSmokeTest). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
AgentTool.Otherconstructor now public. The documented escape hatch ("pass any Java SDKAgentCreateParams.Tool") was previously unreachable from outside the module because of aninternal constructor.rawproperty staysinternal.AgentTool.Toolset20260401Subset(enabled: Set<DefaultTool>)— subset ofagent_toolset_20260401viadefault_config.enabled = false+ per-tooladdConfig.DefaultToolenum:BASH,READ,GLOB,GREP,WEB_SEARCH,WEB_FETCH.AgentTool.McpToolset(serverName, enabled?)— reference a registered MCP server, optional tool-name whitelist.AgentTool.CustomTool(name, description, rawInputSchema)— client-side tools;rawInputSchemakeeps the Java SDK type so nested JSON Schema is fully expressible.McpUrlServer(name, url)+createAgent(mcpServers = ...)register remote MCP servers at agent creation. Auth lives separately in a vault credential targeting the samemcpServerUrl.createSession(vaultIds = ...)attaches vault credentials so the agent can authenticate to MCP servers.SessionStreamEvent.AgentCustomToolUse(id, name, inputJson)— previously absorbed bySessionStreamEvent.Other.Message.toolResults(vararg | List)— bundles multipletool_resultblocks into one user message (required when the assistant emits >1tool_useper turn).ServerToolsealed (WebSearch/WebFetch) +serverToolsparameter oncreateMessage/streamMessage. Mixes freely with client-sidetools = listOf(Tool(...)).Scoping notes
mcp_serversbody +anthropic-beta: mcp-client-2025-04-04header) is not wrapped here. The upstream surface is still moving, so callers use the raw Java SDK directly for that case.class X internal constructor(internal val raw: ...)insdk/src/main/kotlin/com/rimdoo/anthropic/. The only one that should accept external raw injection isAgentTool.Other; the rest (ContentBlock.Other,SessionStreamEvent.Other,MessageStreamEvent.MessageStart/...) are response-side wraps the SDK constructs itself, sointernal constructoris correct on those.Test plan
./gradlew :sdk:test— 134 unit tests pass (39 mappers, 7 DSL, 7 exceptions, 81 client-API smoke).MappersTestentries: everyAgentToolvariant builds,Toolset20260401Subset/McpToolsetreject empty enabled sets,McpUrlServer+ServerTool.WebSearch+ServerTool.WebFetchbuild with every option combination,AgentTool.Other(rawUnion)constructs from outside-style code.ClientApiSmokeTestentries:createAgentwith everyAgentToolvariant +mcpServers,createSessionwithvaultIds,createMessage/streamMessagewithserverTools(alone and mixed withtools).🤖 Generated with Claude Code