-
Notifications
You must be signed in to change notification settings - Fork 209
feat(tool runner): add context parameter to tool run functions #877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
fix(client): don't strip path from filename for skills endpoint
docs: update README with Claude branding - Add Claude sparkle logo to header - Rename to "Claude SDK for TypeScript" - Use "Claude API" terminology instead of "Anthropic API" - Link to TypeScript SDK docs at platform.claude.com - Simplify and consolidate documentation sections Co-Authored-By: Claude <[email protected]>
* "Claude PR Assistant workflow" * "Claude Code Review workflow"
Co-authored-by: Vibeke Tengroth <[email protected]> Co-authored-by: Packy Gallagher <[email protected]>
|
Thank you for the PR! Could you share the background/motivation/use case for this change? |
294d05a to
930d26b
Compare
|
@RobertCraigie would you be able to take a look? |
* feat(api): update via SDK Studio * feat(api): update via SDK Studio * codegen metadata * feat: migrate output_format to output_config.format for structured outputs - Update beta header from structured-outputs-2025-11-13 to structured-outputs-2025-12-15 - Transform deprecated output_format parameter to output_config.format - Add warning when both output_format and output_config.format are provided - Update beta-parser to support parsing from either location - Update tests to expect new output_config.format structure Co-Authored-By: Claude Code (/Users/davidmeadows/stainless/stainless) <[email protected]> * feat: add @deprecated JSDoc tag and update example to use output_config - Add @deprecated JSDoc tag to output_format parameter in BetaParseableMessageCreateParams - Update parsing-zod.ts example to use output_config.format instead of output_format Co-Authored-By: Claude Code (/Users/davidmeadows/stainless/stainless/dist/customer-repos/stainless-sdks/anthropic-typescript) <[email protected]> * fix: throw error instead of warning when both output params provided Co-Authored-By: Claude Code (/Users/davidmeadows/stainless/stainless/dist/customer-repos/stainless-sdks/anthropic-typescript) <[email protected]> * Remove note about beta header injection * clean up things a bit * revert changes * undo a change * undo changes from next * fixup! * fixes * fixup! * fix: move structured output formatting to dedicated function and add to token counting * feat: Test exception case in structured output * feat: improve types and add other unit test for structured output transformation --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> Co-authored-by: Claude Code (/Users/davidmeadows/stainless/stainless) <[email protected]> Co-authored-by: Cameron McAteer <[email protected]>
Add helper functions for integrating with the [Model Context Protocol (MCP) SDK](https://github.com/modelcontextprotocol/sdk). These helpers reduce the boilerplate required to convert MCP types to Anthropic API types from ~100+ lines to single function calls. **New helpers:** - `mcpTool(tool, mcpClient)` - Convert single MCP tool to `BetaRunnableTool` - `mcpTools(tools, mcpClient)` - Convert array of MCP tools to `BetaRunnableTool[]` for use with `toolRunner()` - `mcpMessage(message)` - Convert single MCP `PromptMessage` to `BetaMessageParam` - `mcpMessages(messages)` - Convert array of MCP `PromptMessage` to `BetaMessageParam[]` - `mcpContent(content)` - Convert single MCP content block to Anthropic content block - `mcpResourceToContent(resource)` - Convert MCP resource to content block (document or image) - `mcpResourceToFile(resource)` - Convert MCP resource to `File` for `files.upload()`
felixfbecker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition looks nice but would still be good to understand the motivation/use case. Could you add a PR description?
src/helpers/beta/json-schema.ts
Outdated
| run: (args: NoInfer<FromSchema<Schema>>) => Promisable<string | Array<BetaToolResultContentBlockParam>>; | ||
| run: ( | ||
| args: NoInfer<FromSchema<Schema>>, | ||
| context?: BetaToolRunContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since "context" is a defined term in the context of LLMs, a different name might be better, e.g. meta
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed it to meta
0e56ab6 to
e4f218d
Compare
@felixfbecker It adds metadata to tool runners so they can do some logging/tracing. I’m also preparing an update so we provide an abort signal as well, so tools can be aborted. |
eeb7fab to
7b4849b
Compare
Add context parameter to tool run functions
Adds an optional
metaparameter to toolrunfunctions that provides access to tool invocation metadata.Usage