#6840: Fix assistant identity default agent for global sessions
gateway
size: XS
## Summary
- Resolve assistant identity via the default agent when sessionKey is not agent-scoped (e.g. global/main)
- Keeps Control UI assistant name consistent with configured default agent
## Testing
- Not run (logic-only change)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the gateway’s `agent.identity.get` handler (`src/gateway/server-methods/agent.ts`) to resolve the assistant identity’s agentId via the configured default agent when the provided `sessionKey` isn’t agent-scoped (e.g., `global`/`main`). Concretely, it replaces `resolveAgentIdFromSessionKey(sessionKey)` with `resolveSessionAgentId({ sessionKey, config: cfg })`, so Control UI identity/name selection aligns with `agents.list[].default` rather than always falling back to the hardcoded `main` default.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with minimal risk.
- Change is localized to identity resolution in a single handler and aligns behavior with existing `resolveSessionAgentId` logic used elsewhere. The only issue spotted is an unused import that could fail lint/CI depending on repo settings.
- src/gateway/server-methods/agent.ts
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#6430: feat(protocol): include agent identity in hello-ok handshake response
by astoreyai · 2026-02-01
83.1%
#15792: fix: pass agentId to resolveSessionFilePath in additional call sites
by MisterGuy420 · 2026-02-13
81.2%
#15982: fix: pass agentId to resolveSessionFilePath in reply flow (NX-003)
by automagik-genie · 2026-02-14
78.7%
#9726: feat: add identityDir config for separate identity file location
by rickburn · 2026-02-05
78.7%
#22977: fix(ui): resolve agent names from config in session dropdown
by NikhilGaddam · 2026-02-21
78.5%
#7301: fix(hooks): use resolveAgentIdFromSessionKey instead of split(":")[0]
by tsukhani · 2026-02-02
77.8%
#5097: fix(ui): prefer session label over displayName in dropdown
by d-init-d · 2026-01-31
76.1%
#7516: feat(sessions): Auto-inject From:/To: identity headers in agent-to-...
by RusDyn · 2026-02-02
75.8%
#15852: fix: pass agentId when resolving IRC session paths
by MisterGuy420 · 2026-02-14
75.4%
#13215: fix: pass agentId to loadCostUsageSummary in /usage cost command
by veast · 2026-02-10
74.7%