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

オープン
#2,026 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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 はありません

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

anthropics/anthropic-sdk-python のほかの issue

anthropics/anthropic-sdk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。