fix(engine): scope daemon cache per instance via GPTSCRIPT_DAEMON_INSTANCE #1

Merged
thklein merged 1 commit from fix/daemon-per-instance-keying into main 2026-07-09 07:04:53 +00:00
Owner

Daemons were cached solely by tool ID, so every caller of a daemon tool shared one process. Callers that run multiple instances of the same tool with distinct start-time configuration — notably auth providers, whose issuer/client/secret are baked into the oauth2-proxy at launch — all received the first instance's daemon and therefore its configuration.

startDaemon now derives the cache key from the tool ID plus the value of DaemonInstanceEnvVar (GPTSCRIPT_DAEMON_INSTANCE) when the tool's environment sets it. Callers opt in by exporting a stable per-instance value; without it the key is unchanged (tool ID only), so shared-daemon behaviour is preserved for everything that does not need isolation (e.g. model providers, which inject credentials per request).

Consumed by basepeak-ai/bpai to fix a second OIDC auth provider redirecting to the first provider's IdP.

Unit test: TestComputeDaemonKey.

Daemons were cached solely by tool ID, so every caller of a daemon tool shared one process. Callers that run multiple instances of the same tool with distinct start-time configuration — notably auth providers, whose issuer/client/secret are baked into the oauth2-proxy at launch — all received the first instance's daemon and therefore its configuration. `startDaemon` now derives the cache key from the tool ID plus the value of `DaemonInstanceEnvVar` (`GPTSCRIPT_DAEMON_INSTANCE`) when the tool's environment sets it. Callers opt in by exporting a stable per-instance value; without it the key is unchanged (tool ID only), so shared-daemon behaviour is preserved for everything that does not need isolation (e.g. model providers, which inject credentials per request). Consumed by `basepeak-ai/bpai` to fix a second OIDC auth provider redirecting to the first provider's IdP. Unit test: `TestComputeDaemonKey`.
fix(engine): scope daemon cache per instance via GPTSCRIPT_DAEMON_INSTANCE
Some checks failed
Request reviewers for Dependabot PRs / request_reviewers (pull_request_target) Has been skipped
smoke / check-label (pull_request_target) Failing after 24s
smoke / gpt-4o-mini-2024-07-18 (pull_request_target) Has been skipped
smoke / gpt-4o-2024-08-06 (pull_request_target) Has been skipped
smoke / claude-3-7-sonnet-20250219 (pull_request_target) Has been skipped
integration / integration (ubuntu-22.04) (pull_request) Failing after 2m9s
test / test (ubuntu-22.04) (pull_request) Failing after 2m9s
Validate docs build / validate-docs (pull_request) Failing after 2m19s
integration / integration (windows-latest) (pull_request) Has been cancelled
test / test (windows-latest) (pull_request) Has been cancelled
4b8a263d88
Daemons were cached solely by tool ID, so every caller of a daemon tool shared
one process. Callers that run multiple instances of the same tool with distinct
start-time configuration (notably auth providers, whose issuer/client/secret are
baked into the oauth2-proxy at launch) all received the first instance's daemon
and therefore its configuration — e.g. a second OIDC auth provider redirected to
the first provider's IdP.

startDaemon now derives the cache key from the tool ID plus the value of the
DaemonInstanceEnvVar (GPTSCRIPT_DAEMON_INSTANCE) if the tool's environment sets
it. Callers opt in by exporting a stable per-instance value; without it the key
is unchanged (tool ID only), so shared-daemon behaviour is preserved for
everything that does not need isolation.
thklein deleted branch fix/daemon-per-instance-keying 2026-07-09 07:04:53 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
basepeak-ai/gptscript!1
No description provided.