Skip to content

Commit c6b7c62

Browse files
lex00claude
andcommitted
fix(tool_registry): wrap crash-safe README example in activity block
The simple-loop example was already wrapped in `activity :analyze do`, but the crash-safe example jumped straight to `run_with_session`. The wrapper is required (heartbeat reads need an activity context); add it for consistency with the other five SDK READMEs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent bc9b6c3 commit c6b7c62

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

  • temporalio/lib/temporalio/contrib/tool_registry

temporalio/lib/temporalio/contrib/tool_registry/README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,20 @@ it on retry.
102102
```ruby
103103
require 'temporalio/contrib/tool_registry/session'
104104

105-
results = ToolRegistry::AgenticSession.run_with_session do |session|
106-
registry = ToolRegistry::Registry.new
107-
registry.register(name: 'flag', description: '...',
108-
input_schema: { 'type' => 'object' }) do |input|
109-
session.add_result(input) # use add_result, not session.results <<
110-
'ok' # this string is sent back to the LLM as the tool result
105+
activity :long_analysis do |prompt|
106+
ToolRegistry::AgenticSession.run_with_session do |session|
107+
registry = ToolRegistry::Registry.new
108+
registry.register(name: 'flag', description: '...',
109+
input_schema: { 'type' => 'object' }) do |input|
110+
session.add_result(input) # use add_result, not session.results <<
111+
'ok' # this string is sent back to the LLM as the tool result
112+
end
113+
114+
provider = ToolRegistry::Providers::AnthropicProvider.new(
115+
registry, 'your system prompt', api_key: ENV['ANTHROPIC_API_KEY'])
116+
session.run_tool_loop(provider, registry, prompt)
117+
session.results # return value of block = return value of run_with_session
111118
end
112-
113-
provider = ToolRegistry::Providers::AnthropicProvider.new(
114-
registry, 'your system prompt', api_key: ENV['ANTHROPIC_API_KEY'])
115-
session.run_tool_loop(provider, registry, prompt)
116-
session.results # return value of block = return value of run_with_session
117119
end
118120
```
119121

0 commit comments

Comments
 (0)