Self-hosted managed agent sessions fail after ~60 minutes when sessions_token expires, and environment key fallback cannot access memory stores
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Python
- 星标
- 4.1k
- 派生
- 915
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anthropics/anthropic-sdk-python 的其他 Issue
-
beta_tool validation errors reach the model as "Invalid arguments for function X" with no detail可能已有人在做 @mangeshraut712 于 32 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
anthropics/anthropic-sdk-python#2033 · 3 条评论 ·
-
`AnthropicBedrock` 2.x sends `anthropic_version: 2026-10-21`, which Bedrock rejects for Claude Sonnet 4.5, Opus 4.5 and Opus 4.6可能已有人在做 @charan-rathore 于 36 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
anthropics/anthropic-sdk-python#2031 · 1 条评论 ·
-
Three symlink tests in test_agent_toolset.py are missing the needs_symlinks marker可能已有人在做 @okxint 于 82 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
anthropics/anthropic-sdk-python#1915 · 3 条评论 ·
-
Messages.parse (and AsyncMessages.parse) don't take cache_control?可能已有人在做 @AlphaFDE 于 86 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
anthropics/anthropic-sdk-python#1907 · 2 条评论 ·
-
Windows: os.fchmod in credential write-back bricks the OAuth refresh token可能已有人在做 @OllieinCanada 于 99 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
anthropics/anthropic-sdk-python#1868 · 1 条评论 ·
查看 anthropics/anthropic-sdk-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
compiler-explorer/compiler-explorer#9710 ·
维护者通常 1 天内回复
-
bug harness
难度 2/5 1-3 小时 新手友好度 72/100
mruangutai/harness#2687 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
modal-labs/modal-client#4158 ·
-
kind/bug needs-triage
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 3 天内回复
-
good first issue
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复