refactor(agent-core-v2): remove the agent RPC aggregation layer - #2871
Conversation
- delete src/agent/rpc/ (AgentRPCService, IAgentRPCService, core-api,
prompt-metadata, types) and sink each method's orchestration into its
owning domain service
- prompt: new submit/submitSteer composing disabledTools gating,
MAIN-only session metadata, and engine-side {turn_id} settlement
- skill: activate now returns PromptLaunchResult and writes session
metadata internally (MAIN-only, unified across prompt/steer/skill/
pluginCommand); node-sdk and kap-server drop their edge-side writes
- pluginCommand: new agent-scope domain owning command activation and
the plugin_command.activated domain event
- permissionMode/loop/fullCompaction: new setModeAndBroadcast /
cancelFromUser / cancel; setMode and loop.cancel stay pure for
internal callers
- klient: agentRpcContract split into per-domain contracts; facade
re-routes to domain channels with its public API unchanged
- node-sdk, kap-server, kimi-inspect and the v2 test harness now call
domain services directly; ctx.rpc keeps its name as a composed
adapter
- externally visible: the agentRPCService debug channel is gone and
session metadata writes are now MAIN-agent-only (see changeset)
…domain
Prompt should not own session tool policy: submit no longer accepts or
applies disabledTools. The klient facade keeps its prompt({ disabledTools })
API and composes it edge-side — applying agentToolPolicyService
setSessionDisabledTools before calling agentPromptService.submit, the same
way kap-server's prompt route already does. Over klient, a profile-less
engine now surfaces the raw profile error instead of request.invalid.
Also restores the RPC-removal changeset, which did not make it into the
previous commit.
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09c6704c13
ℹ️ 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".
| if (input.disabledTools !== undefined) { | ||
| await call(scope, 'agentToolPolicyService', 'setSessionDisabledTools', [ | ||
| [...input.disabledTools], |
There was a problem hiding this comment.
Validate prompt payload before applying disabled tools
When prompt() is called with disabledTools and a malformed input payload, this first call persists the session denylist, and only the later agentPromptService.submit call validates/rejects the prompt shape. With klient validation enabled by default, a rejected prompt can still leave tools disabled for subsequent prompts; pre-validate the submit payload before mutating agentToolPolicyService so the composed facade remains atomic on caller input errors.
Useful? React with 👍 / 👎.
The prompt path no longer carries session tool gating on any surface: the klient facade prompt() loses the disabledTools field and calls agentPromptService.submit directly, and the node-sdk SessionPromptRpcInput stops accepting or forwarding it (v1 always ignored the field). Session tool gating remains available through IAgentToolPolicyService.setSessionDisabledTools, composed at the edge the way kap-server's prompt route does; the klient toolPolicy contract added for facade-side composition is removed as unused.
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
Related Issue
No linked issue — the problem is explained below.
Problem
agent-core-v2 had two ways to reach agent-scope behavior: a facade-style
AgentRPCService(src/agent/rpc/) aggregating 12 methods, and direct domain-service calls. Every edge (klient facade, node-sdk, kap-server, kimi-inspect, test harness) had to know which track to take, and orchestration logic (session-metadata writes, telemetry, main-agent broadcast, turn-launch settlement, plugin-command expansion) lived in the RPC facade instead of its owning domain — duplicating edge-side re-implementations (node-sdk and kap-server each re-did the skill metadata write) and relying on implicit knowledge like "Promises cannot cross the klient wire".What changed
Engine: orchestration sinks to owning domains,
agent/rpc/deletedIAgentPromptServicegainssubmit/submitSteer(engine-side{turn_id}settlement, MAIN-only session metadata);IAgentSkillService.activatereturnsPromptLaunchResultand writes session metadata internally; new agent-scopeagent/pluginCommand/domain owns plugin-command activation and theplugin_command.activatedevent.IAgentPermissionModeService.setModeAndBroadcast/IAgentLoopService.cancelFromUser/IAgentFullCompactionService.canceladded;setModeandloop.cancelstay pure for their internal callers.disabledToolsleaves the prompt path entirely: the engine'ssubmitnever accepted it, and the klient facade / node-sdk prompt entries stop carrying it (v1 never consumed the field). Session tool gating stays available throughIAgentToolPolicyService.setSessionDisabledTools, composed at the edge the way kap-server's prompt route does.klient: per-domain contracts, facade API otherwise unchanged
agentRpcContractsplit into per-domain contracts (prompt/skill/loop/permissionMode/command/…); the facade re-routes to domain channels with its wire shapes unchanged (contract-parity holds).Callers and tests
:abort→cancelFromUser), kimi-inspect, and the v2 test harness (ctx.rpckept as a composed adapter) call domain services directly.test/agent/prompt/submit.test.ts,test/agent/pluginCommand/); rpc-domain tests move to their owner domains.Externally visible: the
agentRPCServicedebug channel is gone (per-domain channels serve the same operations); session-metadata writes are MAIN-agent-only; the klient facade and node-sdk prompt entries no longer acceptdisabledTools.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.