From e2d174ac1d4ed3304d9949f04572803467d343cb Mon Sep 17 00:00:00 2001 From: dianed-square <73617011+dianed-square@users.noreply.github.com> Date: Wed, 18 Feb 2026 09:09:04 -0800 Subject: [PATCH] docs: agent session id (#7289) --- .../docs/guides/environment-variables.md | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/documentation/docs/guides/environment-variables.md b/documentation/docs/guides/environment-variables.md index 8f3ba6cf6f..99db4c4226 100644 --- a/documentation/docs/guides/environment-variables.md +++ b/documentation/docs/guides/environment-variables.md @@ -575,7 +575,8 @@ These variables are automatically set by goose during command execution. | Variable | Purpose | Values | Default | |----------|---------|---------|---------| -| `GOOSE_TERMINAL` | Indicates that a command is being executed by goose, enables customizing shell behavior | "1" when set | Unset | +| `GOOSE_TERMINAL` | Indicates that a command is being executed by goose, enables [customizing shell behavior](#customizing-shell-behavior) | "1" when set | Unset | +| `AGENT_SESSION_ID` | The current session ID for [session-isolated workflows](#using-session-ids-in-workflows), automatically available to STDIO extensions and the Developer extension shell commands | Session ID string (e.g., `20260217_5`) | Unset (only set in extension/shell contexts) | ### Customizing Shell Behavior @@ -609,6 +610,24 @@ if [[ -n "$GOOSE_TERMINAL" ]]; then fi ``` +### Using Session IDs in Workflows + +STDIO extensions (local extensions that communicate via standard input/output) and the Developer extension's shell commands automatically receive the `AGENT_SESSION_ID` environment variable. This enables you to create session-isolated workflows and make it easier to: +- Coordinate work across multiple tool calls using session-isolated handoff paths +- Isolate worktrees or temporary files by session +- Debug correlation between artifacts and session history + +The following example shows how a recipe might use the session ID to hand off information between steps: + +```bash +# Create session-specific handoff directory +mkdir -p ~/Desktop/${AGENT_SESSION_ID}/handoff +echo "Results from step 1" > ~/Desktop/${AGENT_SESSION_ID}/handoff/output.txt + +# Later steps in the recipe can read from the same location +cat ~/Desktop/${AGENT_SESSION_ID}/handoff/output.txt +``` + ## Enterprise Environments When deploying goose in enterprise environments, administrators might need to control behavior and infrastructure, or enforce consistent settings across teams. The following environment variables are commonly used: