Skip to content

fix: inherit parent session account binding for subagents#8

Open
0xYiliu wants to merge 2 commits intodkraemerwork:mainfrom
0xYiliu:pr/subagent-account-inheritance
Open

fix: inherit parent session account binding for subagents#8
0xYiliu wants to merge 2 commits intodkraemerwork:mainfrom
0xYiliu:pr/subagent-account-inheritance

Conversation

@0xYiliu
Copy link
Copy Markdown

@0xYiliu 0xYiliu commented Apr 6, 2026

Summary

  • inherit the bound account from the parent session when a subagent starts in a new child session
  • keep in-memory session hints aligned after manual account switching
  • add a regression test covering parent-child session account inheritance

Why

Subagents created by oh-my-openagent run in fresh child sessions. Before this change, those child sessions did not inherit the parent session's account binding, so the plugin fell back to the default sticky account and subagents often used the first configured account.

Notes

This PR is stacked on top of #7. Until #7 merges, this PR includes that prerequisite diff as well.

Validation

  • npm test
  • npm run build

Yiliu added 2 commits April 7, 2026 05:45
Why:
- Users need explicit session-scoped commands to inspect configured OpenAI accounts and switch the current session to a specific account
- The plugin needed session context tracking so these commands can resolve the active session and update the correct binding

What:
- Added codex-account-list and codex-switch-account commands and registered them as primary tools
- Added session context tracking to map session IDs to prompt cache keys for session-scoped account operations
- Added account lookup helpers and tests covering account commands, session context, and runtime fetch behavior

Impact:
- Users can list configured accounts and switch the current session to a selected OpenAI account
- Session-scoped account binding now has the context needed for command-driven switching
Why:
- oh-my-openagent creates subagents in new sessions, so multi-auth could not reuse the parent session account binding
- Under the sticky strategy, new sessions fell back to the default account, which made subagents always use the first account

What:
- Added account binding inheritance by walking the parent session chain for new sessions
- Synced the in-memory session hint after manual account switching to avoid inheriting stale bindings
- Added a runtime fetch regression test covering parent-child session account inheritance

Impact:
- A subagent's first request now inherits the account currently bound to the parent session
- Existing single-session binding behavior is preserved; only delegated multi-session flows are fixed
@0xYiliu 0xYiliu requested a review from dkraemerwork as a code owner April 6, 2026 21:47
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.

1 participant