Skip to content

Add Temporalio.Extensions.ToolRegistry with AgenticSession support#641

Open
lex00 wants to merge 4 commits intotemporalio:mainfrom
lex00:feat/tool-registry
Open

Add Temporalio.Extensions.ToolRegistry with AgenticSession support#641
lex00 wants to merge 4 commits intotemporalio:mainfrom
lex00:feat/tool-registry

Conversation

@lex00
Copy link
Copy Markdown

@lex00 lex00 commented Apr 13, 2026

What was changed

New Temporalio.Extensions.ToolRegistry package for running LLM tool-calling loops inside Temporal activities.

  • ToolRegistry — maps tool names to JSON Schema definitions and handler functions
  • AgenticSession — crash-safe wrapper that checkpoints conversation history via ActivityExecutionContext.HeartbeatAsync on each turn and restores on retry; session survives both activity crashes and provider-side session expiry since state is stored locally
  • Built-in AnthropicProvider and OpenAIProvider
  • Temporalio.Extensions.ToolRegistry.Testing with MockProvider and FakeToolRegistry for unit testing without a live API key
  • ToolRegistry.FromMcpTools — converts a sequence of MCP tool descriptors into a populated registry

Bug fix included

The Anthropic provider now sets is_error: true on tool result maps when a handler throws, matching the Anthropic API spec. A new test (AnthropicProvider_HandlerError_SetsIsError) verifies this using an HttpListener-based mock server. OpenAI has no equivalent field.

Why?

Temporal activities are a natural fit for LLM tool-calling loops, but every team reimplements the same boilerplate. This extension package standardizes the pattern across all six Temporal SDKs. .NET has no framework-level LLM integration (Python's openai_agents/google_adk_agents and TypeScript's @temporalio/ai-sdk are Python/TypeScript only), so this is the recommended path for direct Anthropic/OpenAI calls in .NET.

Proposal: temporalio/proposals#107

Checklist

  1. Related to: Add ToolRegistry + AgenticSession proposal proposals#107
  2. How was this tested: unit tests with MockProvider (no API key required); new AnthropicProvider_HandlerError_SetsIsError test uses HttpListener mock; integration tests gated on RUN_INTEGRATION_TESTS=1
  3. Any docs updates needed? Yes — docs.temporal.io update to follow after merge

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lex00 lex00 requested a review from a team as a code owner April 13, 2026 03:53
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 13, 2026

CLA assistant check
All committers have signed the CLA.

lex00 and others added 3 commits April 12, 2026 22:40
Adds McpTool record and ToolRegistry.FromMcpTools static method that converts
a sequence of MCP tool descriptors into a populated ToolRegistry. Handlers
default to no-ops; callers override with Register after construction. Null
InputSchema is normalized to an empty object schema.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Set is_error=true on Anthropic tool result maps when a handler throws,
  matching the Anthropic API spec; OpenAI has no equivalent field
- Add AnthropicProvider_HandlerError_SetsIsError test using an HttpListener-
  based mock server to verify is_error propagation without a real API key
- Clarify RunToolLoopAsync system param docstring
- Update README to clarify positioning vs Python/TypeScript framework plugins

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ut docs

- Rename AgenticSession.Issues → Results; update SessionCheckpoint JSON key
  'issues' → 'results' and property Issues → Results
- Remove unused system parameter from AgenticSession.RunToolLoopAsync and
  ToolRegistry.RunToolLoopAsync
- Add ScheduleToCloseTimeout guidance to README
- Update all test call sites (AgenticSessionTests, ToolRegistryTests)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants