feat(cli): resolve ping-peer by durable agentSessionId (#1203) - #137
feat(cli): resolve ping-peer by durable agentSessionId (#1203)#137heavygee wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c224cb459
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const exactHub = sessions.filter((session) => session.id === trimmed) | ||
| if (exactHub.length === 1) { | ||
| return exactHub[0]! |
There was a problem hiding this comment.
Redirect stale hub IDs to the current durable peer
When a stale and a current hub row share the same metadata.agentSessionId, supplying the stale row's exact /sessions/<id> value returns it immediately and bypasses the active/newest durable-ID selection below. pingPeer consequently resumes and posts to the stale hub ID rather than the current row, defeating the row-churn behavior this change advertises and potentially reviving a duplicate session. Resolve an exact hub match through its durable-ID group before returning it.
Useful? React with 👍 / 👎.
| function hasValidDshConfiguration(env: LaunchEnvironment): boolean { | ||
| const config = env.HAPI_DSH_ACP_CONFIG?.trim() | ||
| if (!config) return true | ||
| if (!isAbsolute(config)) return false | ||
| try { | ||
| return existsSync(config) && statSync(config).isFile() |
There was a problem hiding this comment.
Validate the effective DSH launch configuration
Valid DSH setups can now be blocked before spawning because this validator diverges from resolveDshAcpCommand: a relative HAPI_DSH_ACP_CONFIG is launchable relative to the runner cwd but is rejected here, and a stale config is still checked even when HAPI_DSH_ACP_ARGS_JSON overrides and ignores it. In either case availability reports invalid_configuration, so all new-session clients disable DSH even though the actual launch specification is usable.
Useful? React with 👍 / 👎.
Hub session ids rotate on resume; metadata.agentSessionId is the durable find-key. ping-peer / inspect_peer / MCP ping_peer now match agentSessionId (exact, prefix, and overseer substring parity), prefer active+newest rows, and still POST to the resolved hub id. Ambiguous/not-found errors include name and hub id hints. Co-authored-by: Cursor <cursoragent@cursor.com>
3c224cb to
74c784f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74c784f1b2
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (tied.length > 1) { | ||
| throwPeerResolveAmbiguous(trimmed, tied, kind) | ||
| } | ||
| return top |
There was a problem hiding this comment.
Reject prefixes spanning multiple durable peers
When an agentSessionId prefix or substring matches different durable peers with unequal activity or timestamps, pickBestPeerMatch silently selects the active/newest row instead of reporting ambiguity, so ping-peer can send a message to an unintended session. Activity/recency should select among churned hub rows only after grouping by the same normalized agentSessionId and flavor; distinct groups must remain ambiguous (the flavor distinction is already required by web/src/components/SessionList.tsx:189-195).
Useful? React with 👍 / 👎.
CI fix (2026-08-29)All checks green after force-push to What failed (not ping-peer logic):
Fix: reset to Still not in soup — needs merge + driver remat for |
Durable find-key for hapi ping-peer so dogfood works on :3006 while the fork PR stays open for upstream prep. Thin tip 93cae0a on live soup. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
hapi ping-peer,hapi inspect-peer, and MCPping_peer/inspect_peernow resolve peers by durablemetadata.agentSessionId(exact, prefix, and overseer substring parity) in addition to hub session id prefix.agentSessionId, then POSTs/resumes using the current hubid(ids still rotate; agentSessionId is the find-key).shared/src/sessionCitation.ts.Part of reply-addressable peer handoffs (tiann/hapi#1203). Does not add fortress/capability HMAC (tiann#1473) or automatic reply loops.
Upstream prep (tiann/hapi)
Ready to open as upstream PR against
tiann/hapi:mainwhen lane allows. Diff is product-only (cli/,shared/).Test plan
bunx vitest run cli/src/modules/pingPeer/(30 tests)bun run typecheckincli/hapi ping-peer 05d9f0f2 "…"delivered to orchestrator sessionMade with Cursor