Skip to content

fix(developer): expose AGENT_SESSION_ID to shell commands - #10428

Merged
alexhancock merged 4 commits into
aaif-goose:mainfrom
johnmatthewtennant:jtennant/berd-session-env
Jul 17, 2026
Merged

fix(developer): expose AGENT_SESSION_ID to shell commands#10428
alexhancock merged 4 commits into
aaif-goose:mainfrom
johnmatthewtennant:jtennant/berd-session-env

Conversation

@johnmatthewtennant

@johnmatthewtennant johnmatthewtennant commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Context

This is a bug fix for Goose's documented AGENT_SESSION_ID contract. Goose exposes the session ID to STDIO extensions and documents it for Developer extension shell commands, but the Developer shell and supported delegated execution paths omit it. Session-isolated workflows therefore see an empty or stale value from shell steps.

Summary

This PR restores AGENT_SESSION_ID across every Developer shell execution path. The value is scoped to each tool call so concurrent sessions in a shared Goose server do not leak identifiers into one another.

Changes

  • Passes ToolCallContext.session_id to each in-process Developer shell invocation.
  • Sets or clears AGENT_SESSION_ID on spawned commands to prevent stale inherited values.
  • Forwards the variable to Flatpak host shells with flatpak-spawn --env and clears it with --unset-env when no session context exists.
  • Includes AGENT_SESSION_ID in ACP CreateTerminalRequest.env when the client owns terminal execution.
  • Covers direct Developer shell execution, environment scoping, Flatpak forwarding, and ACP terminal request construction.

Reviewer-reproducible examples

The reproduction calls DeveloperClient::call_tool with session session-789, executes printenv AGENT_SESSION_ID through the real Developer shell path, and asserts that the command returns session-789.

Red: main returns no session ID

From a clean checkout of main, copy the test developer_client_passes_session_id_to_shell_tool from this PR into crates/goose/src/agents/platform_extensions/developer/mod.rs, then run:

env -u AGENT_SESSION_ID cargo test -p goose --lib agents::platform_extensions::developer::tests::developer_client_passes_session_id_to_shell_tool -- --exact --nocapture

Output excerpt:

assertion `left == right` failed
  left: Some(true)
 right: Some(false)
test agents::platform_extensions::developer::tests::developer_client_passes_session_id_to_shell_tool ... FAILED

test result: FAILED. 0 passed; 1 failed

Green: this branch returns the tool-call session ID

From a clean checkout of this branch, run the same test:

env -u AGENT_SESSION_ID cargo test -p goose --lib agents::platform_extensions::developer::tests::developer_client_passes_session_id_to_shell_tool -- --exact --nocapture

Output excerpt:

running 1 test
test agents::platform_extensions::developer::tests::developer_client_passes_session_id_to_shell_tool ... ok

test result: ok. 1 passed; 0 failed

Supporting checks:

cargo test -p goose --lib terminal_request_includes_agent_session_id -q
cargo test -p goose --lib session_environment_ -q
cargo test -p goose --lib flatpak_session_environment_ -q
cargo fmt --check

These checks passed. The Flatpak path and an external ACP client terminal were not available for live execution in this environment, so focused command and request-construction tests cover those platform-specific paths.

@johnmatthewtennant
johnmatthewtennant marked this pull request as ready for review July 14, 2026 17:52
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/berd-session-env branch from 10e1e7b to c975457 Compare July 14, 2026 17:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10e1e7b713

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/goose/src/agents/platform_extensions/developer/shell.rs Outdated
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/berd-session-env branch from c975457 to 302f7eb Compare July 15, 2026 18:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 302f7eb9b7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/goose/src/agents/platform_extensions/developer/shell.rs Outdated
@johnmatthewtennant
johnmatthewtennant marked this pull request as draft July 15, 2026 19:47
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/berd-session-env branch from 302f7eb to ecfd8bf Compare July 15, 2026 20:18
@johnmatthewtennant johnmatthewtennant changed the title feat: expose session IDs to shell commands fix(developer): expose AGENT_SESSION_ID to shell commands Jul 15, 2026
@johnmatthewtennant
johnmatthewtennant marked this pull request as ready for review July 15, 2026 20:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ecfd8bf9a8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/goose/src/agents/platform_extensions/developer/shell.rs
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/berd-session-env branch from f210046 to 738114f Compare July 16, 2026 13:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 738114f0eb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/goose/src/agents/platform_extensions/developer/mod.rs
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/berd-session-env branch 4 times, most recently from affd24f to dbf65e8 Compare July 17, 2026 09:18
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/berd-session-env branch from dbf65e8 to 48fc166 Compare July 17, 2026 11:40
@alexhancock
alexhancock added this pull request to the merge queue Jul 17, 2026
Merged via the queue into aaif-goose:main with commit 8d5bc5d Jul 17, 2026
25 checks passed
@johnmatthewtennant
johnmatthewtennant deleted the jtennant/berd-session-env branch July 17, 2026 17:34
michaelneale added a commit that referenced this pull request Jul 20, 2026
* origin/main: (24 commits)
  fix(session): create inventory tables atomically with schema version (#10586)
  fix(providers): rewrite oneOf to anyOf in tool schemas for OpenAI-compatible backends (#10571)
  fix(evals): report cache-aware Harbor costs (#10430)
  fix(acp): allow custom model as default for non-local providers (#10438)
  fix(config): require absolute goose path roots (#10454)
  chore(deps): bump astral-sh/setup-uv from 8.2.0 to 8.3.2 (#10541)
  fix(permissions): scope smart approval by request (#10457)
  fix(summon): preserve fixed subrecipe values (#10452)
  chore(deps): bump websocket-driver from 0.7.4 to 0.7.5 in /documentation (#10506)
  fix(flatpak): bundle git so hermit can clone its package registry (#10511)
  feat(hooks): pass working_dir to the Stop hook context (#10296)
  chore(deps): bump actions/setup-java from 5.5.0 to 5.6.0 (#10540)
  chore(deps): bump actions/setup-node from 6 to 7 (#10539)
  chore(deps): bump EmbarkStudios/cargo-deny-action from 2.0.20 to 2.1.1 (#10542)
  chore(deps): bump gradle/actions/setup-gradle from 4.4.3 to 6.2.0 (#10543)
  Add declarative Sakana AI provider for the OpenAI-compatible Fugu API (#10357)
  fix(developer): expose AGENT_SESSION_ID to shell commands (#10428)
  Clean up stale documentation audit findings (#10114)
  Restore model interactions viewer (#10205)
  fix(acp): forward image content chunks to client during live session (#10485)
  ...

# Conflicts:
#	crates/goose/src/session/session_manager.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants