@@ -4,6 +4,7 @@ import { AppError, type NormalizedError } from '@agent-device/kernel/errors';
44import { createAgentDeviceClient } from '../agent-device-client.ts' ;
55import type { AgentDeviceClient } from '../client/client-types.ts' ;
66import type { JsonSchema } from '../commands/command-contract.ts' ;
7+ import { commonInputKeysHiddenFromAiSdk } from '../commands/command-input.ts' ;
78import { resolveCommandFrameworkTier } from '../core/command-descriptor/registry.ts' ;
89import { createCommandToolExecutor , listCommandTools } from '../mcp/command-tools.ts' ;
910import { formatToolErrorText } from '../mcp/tool-error.ts' ;
@@ -49,21 +50,11 @@ export type AgentDeviceTools = {
4950 toolApproval ?: Partial < Record < string , ToolApprovalStatus > > ;
5051} ;
5152
52- // Hidden unconditionally, from both the schema the model sees and the input
53- // `execute` forwards to the shared executor:
54- // - `session` is always pinned by this factory — the whole point is that a
55- // tool call can never target a session other than the one passed in.
56- // - `stateDir` selects which daemon state directory (and therefore which
57- // daemon/session namespace) a call resolves against. Left model-visible,
58- // it would let a call escape the pinned session into another daemon's
59- // state entirely, defeating that guarantee.
60- // - `mcpOutputFormat`, `includeCost`, `responseLevel` are MCP tool-config
61- // knobs, not command arguments; irrelevant here since `execute` below
62- // returns structuredContent directly and never reads a tool's rendered
63- // text, and shaping the response is this factory's decision, not the
64- // model's.
65- const ALWAYS_HIDDEN_FIELDS = [
66- 'session' ,
53+ // MCP tool-config knobs, not command arguments; irrelevant here since
54+ // `execute` below returns structuredContent directly and never reads a tool's
55+ // rendered text. Common pinned fields such as `session`/`platform` come from
56+ // the common input-field table.
57+ const AI_SDK_HIDDEN_MCP_FIELDS = [
6758 'stateDir' ,
6859 'mcpOutputFormat' ,
6960 'includeCost' ,
@@ -104,8 +95,10 @@ export async function createAgentDeviceTools(
10495 } ) ;
10596 const executor = createCommandToolExecutor ( ) ;
10697
107- const hiddenFields = new Set < string > ( ALWAYS_HIDDEN_FIELDS ) ;
108- if ( platform ) hiddenFields . add ( 'platform' ) ;
98+ const hiddenFields = new Set < string > ( [
99+ ...AI_SDK_HIDDEN_MCP_FIELDS ,
100+ ...commonInputKeysHiddenFromAiSdk ( { platformPinned : Boolean ( platform ) } ) ,
101+ ] ) ;
109102
110103 const tools : ToolSet = { } ;
111104 for ( const definition of listCommandTools ( ) ) {
0 commit comments