fix(agent): preserve default-agent session routing compatibility#72414
Conversation
Greptile SummaryThis PR fixes session routing for configured non-main default agents: new Confidence Score: 4/5Safe to merge; logic is sound and well-tested. One minor test-mock fidelity concern noted. No P0 or P1 issues found. The session-key routing logic, the legacy fallback, and the shared-store deduplication are all correctly implemented and covered by focused tests. A single P2 observation about the resolveDefaultAgentId mock in session.test.ts not applying normalizeAgentId keeps the score at 4. No files require special attention. src/agents/command/session.ts carries the most logic and is well-covered by the accompanying tests. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/commands/agent/session.test.ts
Line: 30-38
Comment:
**Test mock omits `normalizeAgentId` on the return value**
The inline mock for `resolveDefaultAgentId` returns the raw `.id` string directly, while the real `resolveDefaultAgentId` in `agent-scope-config.ts` always passes the chosen id through `normalizeAgentId(chosen || DEFAULT_AGENT_ID)` before returning. The divergence means tests won't catch bugs triggered by an unnormalized agent id in config (e.g. `{ id: "MyBot" }` → mock returns `"MyBot"`, real function returns `"mybot"`).
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(clownfish): address review for ghcra..." | Re-trigger Greptile |
b028d73 to
5c81bf6
Compare
|
ProjectClownfish follow-up pushed: 5c81bf6 Fix:
Blacksmith validation:
|
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Implicit cross-agent session migration copies full SessionEntry (auth/config/ACP) from legacy main store into default agent store
Description
During migration, the code copies the entire legacy Impacts:
Vulnerable code: // Copies full legacy entry into a different agent's session key
opts.sessionStore[opts.sessionKey] = { ...legacyEntry };RecommendationAvoid copying the entire legacy Safer options:
Example (minimal-field migration): const { sessionId, updatedAt } = legacyEntry;
opts.sessionStore[opts.sessionKey] = { sessionId, updatedAt: Date.now() };
// do NOT carry over auth/acp/exec overrides, delivery context, plugin owner, etc.Additionally, consider validating store file permissions / ownership and documenting that session stores must not be writable by untrusted users. Analyzed PR: #72414 at commit Last updated on: 2026-04-27T22:04:56Z |
|
ProjectClownfish follow-up on latest head a4a9185122:
|
a4a9185 to
9e1db57
Compare
|
ProjectClownfish rebased follow-up on latest head 9e1db57:
|
…nclaw#72414) * fix(agent): preserve default-agent session routing compatibility * fix(clownfish): address review for ghcrawl-207038-agentic-merge (1) * fix(agent): migrate legacy default-agent sessions * fix(slack): use narrow agent runtime import
…nclaw#72414) * fix(agent): preserve default-agent session routing compatibility * fix(clownfish): address review for ghcrawl-207038-agentic-merge (1) * fix(agent): migrate legacy default-agent sessions * fix(slack): use narrow agent runtime import
…nclaw#72414) * fix(agent): preserve default-agent session routing compatibility * fix(clownfish): address review for ghcrawl-207038-agentic-merge (1) * fix(agent): migrate legacy default-agent sessions * fix(slack): use narrow agent runtime import
…nclaw#72414) * fix(agent): preserve default-agent session routing compatibility * fix(clownfish): address review for ghcrawl-207038-agentic-merge (1) * fix(agent): migrate legacy default-agent sessions * fix(slack): use narrow agent runtime import
…nclaw#72414) * fix(agent): preserve default-agent session routing compatibility * fix(clownfish): address review for ghcrawl-207038-agentic-merge (1) * fix(agent): migrate legacy default-agent sessions * fix(slack): use narrow agent runtime import
…nclaw#72414) * fix(agent): preserve default-agent session routing compatibility * fix(clownfish): address review for ghcrawl-207038-agentic-merge (1) * fix(agent): migrate legacy default-agent sessions * fix(slack): use narrow agent runtime import
Summary
Credit
This carries forward the useful work from @mushuiyu886 in #64108 and related default-agent routing analysis from #56453.
Validation
pnpm -s vitest run src/commands/agent/session.test.ts src/agents/command/session.resolve-session-key.test.ts src/config/sessions/session-key.test.tspnpm check:changedFixes #63992. Related #56370, #56453, #42009.
ProjectClownfish replacement details: