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

Abierto
#2,026 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Python
Estrellas
4.1k
Forks
915
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de anthropics/anthropic-sdk-python

Todos los issues de anthropics/anthropic-sdk-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.