← 输入框|github.com|刷新
Skip to content

Add workflow-session activity cache sample - #399

Draft
THardy98 wants to merge 12 commits into
mainfrom
demo/activity-session-cache
Draft

THardy98 wants to merge 12 commits into
mainfrom
demo/activity-session-cache

Conversation

@THardy98

@THardy98 THardy98 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What was changed

  • activity_sessions: a worker pool compares activity affinity off vs on for workflows that reuse worker-local conversation history. Updated to the scope API: workflow.activity_session(ActivitySessionOptions(placement=UseWorkflowSession())) and Worker(session_config=WorkerSessionConfig()).
  • single_session (new): two single-session workers (SingleSessionAdmission(stable_identity=...)) serve agent workflows whose turns run as updates inside an activity session scope. The run checks that each agent binds to one worker, the bound worker takes no other workflow, and the binding survives a worker crash and restart that reuses the stable identity.

Why?

End-to-end demos of the Sessions API (activity affinity and single-session workers) for the AgentCore demo.

Checklist

  1. Closes: N/A
  2. How was this tested: both samples and their opt-in integration tests (TEMPORAL_TEST_ACTIVITY_SESSION_SAMPLE=1, TEMPORAL_TEST_SINGLE_SESSION_SAMPLE=1) pass against a server built from temporalio/temporal shivam/agentcore-single-session, using sdk-python#1979.
  3. Any docs updates needed? No; experimental, documented in each sample's README.

THardy98 and others added 12 commits July 29, 2026 14:13
Simulate a slow context load on cache misses, scale the default run to
4 workers x 20 workflows x 5 steps, and stream activity events to the
parent for an optional live view and a side-by-side summary with an
impact table (context loads, cache copies, latency).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each step now needs every earlier conversation turn. A worker fetches
only the turns it is missing, with simulated latency per turn, so stale
workers pay proportionally and the owner under affinity never fetches.
The strip, live view, impact table, and verification report turns
fetched instead of whole-context cache hits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use `workflow.activity_session(ActivitySessionOptions(placement=UseWorkflowSession()))`
and `Worker(session_config=WorkerSessionConfig())`, matching the current
sdk-python#1979 API.
Two single-session workers, each with its own stable identity, serve agent
workflows that run every turn as an update inside an activity session scope.
The run shows each agent binding to one worker, the bound worker taking no
other workflow, and the binding surviving a worker crash and restart that
reuses the stable identity, with the session's workspace intact.
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.

1 participant