Self-hosted managed agent sessions fail after ~60 minutes when sessions_token expires, and environment key fallback cannot access memory stores

Đang mở
#2,026 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
authentication, backend

Hướng nghiên cứu

Start with src/anthropic/lib/environments/_worker.py, focusing on _sessions_token_from_secret(...) and EnvironmentWorker._handle_item(...), then inspect SessionMemoryStores(...) to understand the credential requirement. Check how the worker obtains and uses the session token during long-running work. Done means the supported credential flow for sessions that outlast token expiry is clear and memory-store calls can continue; the issue does not identify tests.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

We’re seeing a blocker with self-hosted Claude managed agents running on anthropics/anthropic-sdk-python at commit bcd55fe1d3f0f1240765f8cef04295b67337f55a.

Problem
When a self-hosted session runs for about 60 minutes, the per-work-item sessions_token appears to expire exactly at that point. After that, requests start returning 401 Unauthorized.

The worker currently uses the session token extracted from the work item secret for session-level calls and memory-store operations. This is a problem because:

the session token is required for memory-store endpoints
the environment key can be used as a fallback for some work/session operations
but the environment key does not work with memory stores
So when the session token expires, we hit a catch-22:

session token → expired, causes 401s
environment key → works for some calls, but cannot access memory stores
Impact
This breaks long-running self-hosted sessions that rely on memory stores. The session can continue from a work-lease perspective, but the SDK has no obvious way to renew the session token while preserving memory-store access.

Evidence / code path
In the SDK, the self-hosted worker extracts a sessions_token from the work secret and uses it as the bearer credential for session calls:

src/anthropic/lib/environments/_worker.py
credential extraction and fallback logic around sessions_token
memory-store setup requires the session token and explicitly fails if only the environment key is available
The relevant code path appears to be:

_sessions_token_from_secret(...)
EnvironmentWorker._handle_item(...)
memory store initialization in SessionMemoryStores(...)
Expected behavior
For long-running managed-agent sessions, there should be a supported way to:

refresh or rotate the session token before expiry, or
continue memory-store operations after token refresh, or
use a supported credential flow that does not break memory-store access after 60 minutes.
Actual behavior
After ~60 minutes:

requests start failing with 401
session token appears expired
environment-key fallback is not usable for memory stores
long-running sessions become effectively stuck
Questions
Is there a supported way to renew a session token for self-hosted managed agents?
Are session tokens expected to expire after 60 minutes?
If so, what is the supported approach for long-running sessions that need memory stores?
Should the worker SDK be refreshed to re-fetch or rotate the token during a session?
Environment
Repository: anthropics/anthropic-sdk-python
Commit: bcd55fe1d3f0f1240765f8cef04295b67337f55a
Relevant feature: Claude managed agents / self-hosted environment / memory stores

Ngôn ngữ chính
Python
Star
4.1k
Fork
915
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của anthropics/anthropic-sdk-python

Tất cả issue của anthropics/anthropic-sdk-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.