Skip to content

refactor(server): decouple WorkingDir from RuntimeConfig in SessionManager#3602

Open
Piyush0049 wants to merge 1 commit into
docker:mainfrom
Piyush0049:fix/session-manager-config-leak
Open

refactor(server): decouple WorkingDir from RuntimeConfig in SessionManager#3602
Piyush0049 wants to merge 1 commit into
docker:mainfrom
Piyush0049:fix/session-manager-config-leak

Conversation

@Piyush0049

Copy link
Copy Markdown
Contributor

Description

This PR resolves an architectural TODO regarding configuration leakage inside the SessionManager.

Previously, the SessionManager was mutating the global CLI RuntimeConfig by performing a heavy .Clone() operation on every session request just to inject the session's specific WorkingDir.

Instead of overriding the config's WorkingDir and passing a mutated copy down to the team loader, the session's working directory is now passed cleanly via a new teamloader.WithWorkingDir() functional option. This allows the backend to treat the RuntimeConfig as a pristine, read-only global context, eliminating the clone hack in the hot path.

Changes Made

  • pkg/teamloader: Added a WithWorkingDir() functional option and updated the fallback coalescing (cmp.Or) so tests/CLI execution remain 100% backwards compatible.
  • pkg/server: Removed rc := sm.runConfig.Clone() inside RunSession and ferried the WorkingDir via the new option.
  • Removed the maintainer's TODO as the structural weirdness is fully resolved.

Validation

  • Code builds successfully (task build / go build ./...)
  • Linter shows no new issues (task lint / go vet)
  • Core server and teamloader tests pass (go test ./pkg/server ./pkg/teamloader)

…nager

Eliminates the hacky \.Clone()\ of the global CLI \RuntimeConfig\ inside the \SessionManager\'s per-session path.

Instead of overriding the config's \WorkingDir\ and passing the mutated copy down to the team loader, the session's working directory is now passed cleanly via a new \	eamloader.WithWorkingDir()\ functional option. This treats the \RuntimeConfig\ as a proper read-only global context and resolves a lingering TODO left by maintainers regarding configuration leak.
@Piyush0049 Piyush0049 requested a review from a team as a code owner July 11, 2026 12:20
@aheritier aheritier added area/agent For work that has to do with the general agent loop/agentic features of the app area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) kind/refactor PR refactors code without behavior change labels Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent For work that has to do with the general agent loop/agentic features of the app area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) kind/refactor PR refactors code without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants