Add tool_registry incident-triage example#303
Open
lex00 wants to merge 5 commits intotemporalio:mainfrom
Open
Conversation
Multi-step LLM activity demonstrating temporalio.contrib.tool_registry end-to-end. AgenticSession with heartbeat checkpointing, MCP HTTP integration via sidecar, human-in-the-loop via companion workflow, and a testable activity refactor (build_triage_registry + TriageDeps). Includes unit tests using MockProvider with no API key required.
|
|
1 similar comment
|
|
Followup to a898cf4 to bring the new sample into compliance with samples-python conventions: examples are listed in the root README and ship as proper Python packages with __init__.py.
Followup to a898cf4. The approval handler relies on a deterministic workflow ID so that activity retries re-attach to the existing approval workflow rather than spamming the operator. Without an explicit conflict policy, the default ALLOW_DUPLICATE silently allows a new approval workflow to start once the previous one closes. USE_EXISTING enforces the contract: if a workflow with this ID is running, attach to it; otherwise allow a fresh one.
The approval handler blocks on handle.result() for as long as the operator takes to decide. AgenticSession only heartbeats between LLM turns, so a multi-hour wait inside this handler would trigger heartbeat timeout (default 120s) and kill the activity. Spawn a ticker task that fires activity.heartbeat() every 30s for the duration of the wait, cancelled in finally when handle.result() returns. Survives realistic operator delays without churn. Existing tests still pass (the test path uses a fake deps record that doesn't go through this code path).
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.
Adds a new sample under
tool_registry_incident_triage/demonstratingtemporalio.contrib.tool_registryend-to-end.The example includes:
AgenticSessionwith heartbeat checkpointing.build_triage_registry(alert, session, deps) -> (registry, get_result)plus aTriageDepsrecord of I/O callables, so unit tests substitute fakes and drive the registry viaMockProvider.Unit tests in
tool_registry_incident_triage/tests/useMockProviderand require no API key or running Temporal server.Cross-references the SDK PR (temporalio/sdk-python#1435) which adds the
temporalio.contrib.tool_registrypackage itself.