Repository navigation
Conversation
Greptile SummaryThis PR introduces a new blocking Two issues need attention before merging:
Confidence Score: 4/5Not safe to merge until the CHANGELOG merge conflict is resolved and the routeOverride.agentId gap is addressed. Two P0/P1 issues block clean merge: an unresolved merge conflict in CHANGELOG.md that will ship raw conflict markers, and a public API type field (routeOverride.agentId) that is declared but silently ignored in dispatch, creating a misleading contract for plugin authors. The core hook logic, timeout handling, and test coverage are otherwise solid. CHANGELOG.md (merge conflict) and src/plugins/types.ts together with dispatch-from-config.ts (agentId contract gap)
|
| Filename | Overview |
|---|---|
| CHANGELOG.md | Contains unresolved git merge conflict markers from a merge with main; must be resolved before this file is correct. |
| src/auto-reply/reply/dispatch-from-config.ts | Core logic for the pre_route feature: duplicate guard moved before hooks, timeout-wrapped runPreRoute call added, effectiveCtx plumbed through all downstream call sites. Logic is sound, but routeOverride.agentId from the result type is never consumed here. |
| src/plugins/types.ts | Adds pre_route hook types; PluginHookPreRouteResult.routeOverride.agentId is declared but never applied in dispatch logic, creating a misleading public API contract. |
| src/plugins/hooks.ts | Adds runPreRoute to the hook runner via the existing runClaimingHook pattern; consistent with other typed hook implementations. |
| src/auto-reply/reply/dispatch-from-config.test.ts | Adds well-structured tests for duplicate deduplication, session/account override, account fallback from session store, and timeout fail-open behavior. |
| src/plugins/wired-hooks-pre-route.test.ts | New test file covering first-handled-wins semantics and handler failure continuation for the pre_route hook runner. |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: CHANGELOG.md
Line: 19-27
Comment:
**Unresolved merge conflict markers**
`CHANGELOG.md` contains raw git conflict markers (`<<<<<<< HEAD`, `=======`, `>>>>>>> main`) that were never resolved. This will ship these markers as literal content in the changelog.
The conflict needs to be manually resolved by combining the entries from both sides. Based on the diff, the intended content from this branch is the `pre_route` hook entry and the two Docs/zh-CN entries, while `main` added the LLM idle-stream timeout, OpenAI/Responses verbosity, and Android notification entries. All of these should appear in the final merged list.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/plugins/types.ts
Line: 2083-2090
Comment:
**`routeOverride.agentId` declared but never consumed**
`PluginHookPreRouteResult` exposes `routeOverride.agentId` as a valid override field in the public type contract, but `dispatch-from-config.ts` never reads or applies it when processing the result. In the override-application block (around line 267 of the updated dispatch file), only `sessionKey` and `accountId` are extracted from `routeOverride` — `agentId` is completely ignored.
Plugin authors who follow this type and return a `routeOverride` containing an `agentId` will have their override silently dropped, with no routing effect and no error. Either the field needs to be wired into the dispatch logic, or it should be removed from the exported type until a future version implements it.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix: merge upstream changes and resolve ..." | Re-trigger Greptile
| <<<<<<< HEAD | ||
| - Docs/zh-CN: add a Chinese Diffs tool page so Chinese readers can access the full Diffs viewer, file-rendering, security, and troubleshooting docs. (#40773) Thanks @elliotllliu. | ||
| - Docs/zh-CN: align the Chinese Diffs tool page with the current English source and generated translation metadata. Thanks @gumadeiras. | ||
| - Plugins/hooks: add a blocking `pre_route` typed hook that can override route/session for the current inbound turn, enabling dynamic route provisioning to apply on the first inbound message instead of waiting for a follow-up turn. | ||
| ======= | ||
| - Agents/LLM: add a configurable idle-stream timeout for embedded runner requests so stalled model streams abort cleanly instead of hanging until the broader run timeout fires. (#55072) Thanks @liuy. | ||
| - OpenAI/Responses: forward configured `text.verbosity` across Responses HTTP and WebSocket transports, surface it in `/status`, and keep per-agent verbosity precedence aligned with runtime behavior. (#47106) Thanks @merc1305 and @vincentkoc. | ||
| - Android/notifications: add notification-forwarding controls with package filtering, quiet hours, rate limiting, and safer picker behavior for forwarded notification events. (#40175) Thanks @nimbleenigma. | ||
| >>>>>>> main |
There was a problem hiding this comment.
Unresolved merge conflict markers
CHANGELOG.md contains raw git conflict markers (<<<<<<< HEAD, =======, >>>>>>> main) that were never resolved. This will ship these markers as literal content in the changelog.
The conflict needs to be manually resolved by combining the entries from both sides. Based on the diff, the intended content from this branch is the pre_route hook entry and the two Docs/zh-CN entries, while main added the LLM idle-stream timeout, OpenAI/Responses verbosity, and Android notification entries. All of these should appear in the final merged list.
Prompt To Fix With AI
This is a comment left during a code review.
Path: CHANGELOG.md
Line: 19-27
Comment:
**Unresolved merge conflict markers**
`CHANGELOG.md` contains raw git conflict markers (`<<<<<<< HEAD`, `=======`, `>>>>>>> main`) that were never resolved. This will ship these markers as literal content in the changelog.
The conflict needs to be manually resolved by combining the entries from both sides. Based on the diff, the intended content from this branch is the `pre_route` hook entry and the two Docs/zh-CN entries, while `main` added the LLM idle-stream timeout, OpenAI/Responses verbosity, and Android notification entries. All of these should appear in the final merged list.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Sorry for the oversight. I've cleaned up the merge markers in CHANGELOG.md and pushed the fix. It should be clear now. Thanks for catching that!
| export type PluginHookPreRouteResult = { | ||
| handled: boolean; | ||
| routeOverride?: { | ||
| sessionKey: string; | ||
| agentId?: string; | ||
| accountId?: string; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
routeOverride.agentId declared but never consumed
PluginHookPreRouteResult exposes routeOverride.agentId as a valid override field in the public type contract, but dispatch-from-config.ts never reads or applies it when processing the result. In the override-application block (around line 267 of the updated dispatch file), only sessionKey and accountId are extracted from routeOverride — agentId is completely ignored.
Plugin authors who follow this type and return a routeOverride containing an agentId will have their override silently dropped, with no routing effect and no error. Either the field needs to be wired into the dispatch logic, or it should be removed from the exported type until a future version implements it.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/plugins/types.ts
Line: 2083-2090
Comment:
**`routeOverride.agentId` declared but never consumed**
`PluginHookPreRouteResult` exposes `routeOverride.agentId` as a valid override field in the public type contract, but `dispatch-from-config.ts` never reads or applies it when processing the result. In the override-application block (around line 267 of the updated dispatch file), only `sessionKey` and `accountId` are extracted from `routeOverride` — `agentId` is completely ignored.
Plugin authors who follow this type and return a `routeOverride` containing an `agentId` will have their override silently dropped, with no routing effect and no error. Either the field needs to be wired into the dispatch logic, or it should be removed from the exported type until a future version implements it.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Implemented.
routeOverride.agentId is now consumed in dispatch-from-config by threading it into session-store lookup resolution.
Specifically, pre-route now captures agentId and uses it for both override-account fallback lookup and the main session-store lookup path, so plugin-provided agent overrides have routing effect.
Added a regression test to verify the override reaches resolveStorePath with the expected agentId.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 014642b114
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ...ctx, | ||
| SessionKey: resolvedSessionKey, | ||
| AccountId: resolvedAccountId, | ||
| }; |
There was a problem hiding this comment.
Apply pre_route override to native command target session
The pre-route override only rewrites SessionKey/AccountId in effectiveCtx, but native-command flows still prioritize CommandTargetSessionKey in resolveSessionStoreLookup, so ACP/send-policy routing can continue on the old session while outbound routing uses the new one. This makes pre_route overrides inconsistent or ineffective for native command turns (for example slash-command resets targeting a specific session). When applying a pre_route override, update the native command target session as well (or change lookup precedence) so all downstream dispatch logic uses the same routed session.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Implemented.
When pre_route returns a routeOverride.sessionKey, we now also sync native command targeting so downstream lookup/dispatch uses a single routed session consistently.
- Updated effectiveCtx to rewrite CommandTargetSessionKey for native turns when the route is overridden.
- Updated the session-store fallback lookup path (when only sessionKey is overridden) to use the overridden native command target as well.
- Added a regression test covering native command + pre_route override to verify session store lookup resolves against the overridden session.
| - Agents/MCP: materialize bundle MCP tools with provider-safe names (`serverName__toolName`), support optional `streamable-http` transport selection plus per-server connection timeouts, and preserve real tool results from aborted/error turns unless truncation explicitly drops them. (#49505) Thanks @ziomancer. | ||
| - Plugins/hooks: add a `before_install` hook with structured request provenance, built-in scan status, and install-target metadata so external security scanners and policy engines can review and block skill, plugin package, plugin bundle, and single-file plugin installs. (#56050) thanks @odysseus0. | ||
| - ACP/plugins: add an explicit default-off ACPX plugin-tools MCP bridge config, document the trust boundary, and harden the built-in bridge packaging/logging path so global installs and stdio MCP sessions work reliably. (#56867) Thanks @joe2643. | ||
| <<<<<<< HEAD |
There was a problem hiding this comment.
Remove unresolved merge markers from changelog
This commit leaves Git conflict markers in CHANGELOG.md, which means the unreleased section now contains unresolved branch state instead of valid release notes. That can break changelog parsing/release-note generation and will publish visibly corrupted notes until the conflict is resolved.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Sorry for the oversight. I've cleaned up the merge markers in CHANGELOG.md and pushed the fix. It should be clear now. Thanks for catching that!
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fc20c3163
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const shouldSyncNativeCommandTargetSession = | ||
| ctx.CommandSource === "native" && | ||
| resolvedSessionKey !== (ctx.CommandTargetSessionKey?.trim() || undefined); |
There was a problem hiding this comment.
Preserve native command target when no pre_route override
Gate the CommandTargetSessionKey rewrite on an actual pre-route session override. As written, resolvedSessionKey starts from ctx.SessionKey, so any native turn that already has a different CommandTargetSessionKey satisfies this condition even when pre_route did nothing; the code then overwrites the original target with the source session. That reroutes targeted native commands (e.g., ACP/slash actions aimed at another session) back to the caller session and breaks existing targeting behavior.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Implemented: CommandTargetSessionKey sync is now gated by an actual pre_route session override. Native command targets are preserved when no override is returned, and a regression test was added to lock this behavior.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e1a024439c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ...inboundClaimContext, | ||
| sessionKey: resolvedSessionKey, | ||
| }, |
There was a problem hiding this comment.
Use native target session in pre_route hook context
For native-command turns, the effective dispatch target is CommandTargetSessionKey (when present), but the pre-route hook context is currently populated from resolvedSessionKey, which starts as ctx.SessionKey. This means plugins evaluating pre_route see the caller session instead of the actual native command target, so routing decisions can be made against the wrong session (for example ACP/slash actions aimed at a different session). Build the pre-route context session key with the same native-target precedence used for dispatch/session lookup.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Implemented: pre_route hook context now uses native target precedence (CommandTargetSessionKey when present) for sessionKey, and a regression test was added to verify plugin hooks see the actual native command target session.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35e0dfc689
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return await Promise.race([ | ||
| params.run(), | ||
| new Promise<undefined>((resolve) => { |
There was a problem hiding this comment.
Cancel timed-out pre_route executions
runPreRouteWithTimeout uses Promise.race to fail open after 8s, but the original params.run() continues running in the background with no cancellation or concurrency cap. If a plugin pre_route handler hangs (for example on a stuck network call), each inbound message creates another long-lived in-flight hook; dispatch keeps progressing, so these pile up and can exhaust memory/sockets or apply delayed side effects out of order. The timeout path should actively cancel or otherwise bound outstanding pre_route executions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed. runPreRouteWithTimeout now creates an AbortController internally and calls controller.abort() when the timeout fires. runPreRoute in hooks.ts accepts an optional signal?: AbortSignal and checks signal.aborted between handler iterations, so timed-out executions stop at the next handler boundary rather than continuing to run in the background.
|
Great, I really need it |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ecd148527c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const sessionStoreEntry = resolveSessionStoreLookup(effectiveCtx, cfg, { | ||
| agentId: resolvedRouteAgentId, | ||
| }); |
There was a problem hiding this comment.
Propagate pre_route agentId override to reply execution
The routeOverride.agentId from pre_route is only used in this resolveSessionStoreLookup call and is never threaded into the actual turn execution path. Downstream logic still resolves the active agent from ctx.CommandTargetSessionKey || ctx.SessionKey (see src/auto-reply/reply/get-reply.ts), so an override like { sessionKey: "session:override:...", agentId: "codex" } can still execute on the default agent. This makes agent-targeted pre-routing inconsistent and can send turns to the wrong workspace/model unless the plugin also encodes the agent in the session key.
Useful? React with 👍 / 👎.
|
Great work on this PR! The pre_route hook addresses a critical gap in the routing architecture. The design is solid |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aea8134e57
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const sessionStoreEntry = resolveSessionStoreLookup(effectiveCtx, cfg, { | ||
| agentId: resolvedRouteAgentId, | ||
| }); |
There was a problem hiding this comment.
Propagate pre_route agent override into dispatch context
routeOverride.agentId is stored in resolvedRouteAgentId but only used for session-store path lookups, so reply execution can still run under the wrong agent when the override session key does not embed an agent id. In this path, replyResolver receives only effectiveCtx, and getReplyFromConfig later resolves agent selection from ctx.CommandTargetSessionKey || ctx.SessionKey (src/auto-reply/reply/get-reply.ts), which ignores the pre-route agent override. Fresh evidence in this commit is that resolvedRouteAgentId is introduced and consumed for resolveSessionStoreLookup(...) only, without being threaded into the downstream agent-selection path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed. Added agentIdOverride?: string to GetReplyOptions. get-reply.ts now checks opts?.agentIdOverride before falling back to session-key derivation, so the override controls which agent workspace, model config, and tools are used for the entire turn. dispatch-from-config.ts forwards resolvedRouteAgentId (from the pre_route routeOverride) as agentIdOverride when calling the reply resolver.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6d3e3d176
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const handlerResult = await ( | ||
| hook.handler as ( | ||
| event: unknown, | ||
| ctx: unknown, | ||
| ) => Promise<PluginHookPreRouteResult | void> |
There was a problem hiding this comment.
Pass AbortSignal into pre_route handlers
The timeout path still cannot cancel a stuck pre_route handler: runPreRouteWithTimeout aborts a signal after 8s, but runPreRoute awaits hook.handler(event, ctx) directly, so a hanging first handler keeps running in the background and each inbound message can add another long-lived in-flight promise. Fresh evidence in this commit is that runPreRoute now accepts signal but does not propagate it to handlers (or enforce a per-handler timeout), so the abort only prevents later iterations and does not stop the active one.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I updated the pre_route hook contract and runner to pass an AbortSignal into handlers, and the runner now forwards the timeout signal to each handler invocation. I also added regression tests to verify both signal propagation and the already-aborted behavior. This keeps timeout behavior bounded and prevents silent drift in future changes.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f1486df76
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ...params.replyOptions, | ||
| typingPolicy: typing.typingPolicy, | ||
| suppressTyping: typing.suppressTyping, | ||
| agentIdOverride: resolvedRouteAgentId ?? params.replyOptions?.agentIdOverride, |
There was a problem hiding this comment.
Apply pre_route agent override before ACP dispatch
When pre_route returns { routeOverride: { sessionKey, agentId } } for a session key that does not embed the agent, this change only forwards agentIdOverride into getReplyFromConfig here, but ACP dispatch is attempted earlier via tryDispatchAcpReply using only sessionKey. In ACP-enabled turns that means ACP resolution still derives the agent from the session key/store path and can miss the intended agent session, causing the turn to bypass ACP and execute on the wrong path. Please thread the pre-route agentId override into ACP resolution/dispatch as well so routing is consistent across both ACP and non-ACP execution.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I have fixed this by threading routeOverride.agentId from pre_route into the actual reply execution path, so it now affects turn-time agent resolution instead of being used only for session-store lookup. I also added a regression test to ensure this override is preserved end-to-end.
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close: the same pre-routing hook problem is now tracked by #81061 with active implementation PR #81198, while this branch is stale against current hook contracts and still has correctness, proof, and trust-boundary blockers. Canonical path: Consolidate pre-routing hook review on #81061 and #81198, while leaving binding-level content routing decisions on #13304. So I’m closing this here and keeping the remaining discussion on #81061, #81198, and #13304. Review detailsBest possible solution: Consolidate pre-routing hook review on #81061 and #81198, while leaving binding-level content routing decisions on #13304. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes a new public plugin routing hook rather than fixing broken behavior under an existing documented contract. Source inspection of current main shows no Is this the best way to solve the issue? No as-is: the branch targets old hook/reply option surfaces and misses current dedupe and ACP routing contracts. The safer solution is to continue the current-design review in #81198 and move any unique semantics there. Security review: Security review needs attention: The diff adds a trusted-plugin route override authority and would need explicit scope, boundary, and audit semantics before merge.
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 225e48f63291. |
Summary
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
Regression Test Plan (if applicable)
User-visible / Behavior Changes
Diagram (if applicable)
Before:
[user inbound message] -> [dispatch starts] -> [non-blocking hook observes message] -> [override cannot reliably affect current turn]
After:
[user inbound message] -> [duplicate guard] -> [blocking pre_route hook] -> [optional route/session override] -> [dispatch continues in same turn]
Security Impact (required)
Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Targeted verification run:
Human Verification (required)
Review Conversations
Compatibility / Migration
Risks and Mitigations