fix: address review feedback on sessions_manage
- Remove `instructions` parameter — sessions.compact gateway schema only accepts `key` and `maxLines` (additionalProperties: false), so passing instructions would be rejected at runtime - Add TODO for SessionAccessAction "manage" variant (currently uses "send" for visibility guard error messages) - Classify sessions_manage as mutating tool in tool-mutation.ts to prevent silent error suppression Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ef7ce1822d
commit
db88d3b463
@ -7,6 +7,7 @@ const MUTATING_TOOL_NAMES = new Set([
|
||||
"process",
|
||||
"message",
|
||||
"sessions_send",
|
||||
"sessions_manage",
|
||||
"cron",
|
||||
"gateway",
|
||||
"canvas",
|
||||
@ -107,6 +108,7 @@ export function isMutatingToolCall(toolName: string, args: unknown): boolean {
|
||||
case "exec":
|
||||
case "bash":
|
||||
case "sessions_send":
|
||||
case "sessions_manage":
|
||||
return true;
|
||||
case "process":
|
||||
return action != null && PROCESS_MUTATING_ACTIONS.has(action);
|
||||
|
||||
@ -18,7 +18,6 @@ const SESSIONS_MANAGE_ACTIONS = ["compact", "reset"] as const;
|
||||
const SessionsManageToolSchema = Type.Object({
|
||||
sessionKey: Type.String(),
|
||||
action: stringEnum(SESSIONS_MANAGE_ACTIONS),
|
||||
instructions: Type.Optional(Type.String()),
|
||||
});
|
||||
|
||||
export function createSessionsManageTool(opts?: {
|
||||
@ -36,7 +35,6 @@ export function createSessionsManageTool(opts?: {
|
||||
const params = args as Record<string, unknown>;
|
||||
const sessionKeyParam = readStringParam(params, "sessionKey", { required: true });
|
||||
const action = readStringParam(params, "action", { required: true });
|
||||
const instructions = readStringParam(params, "instructions");
|
||||
|
||||
if (!SESSIONS_MANAGE_ACTIONS.includes(action as (typeof SESSIONS_MANAGE_ACTIONS)[number])) {
|
||||
return jsonResult({ status: "error", error: "action must be 'compact' or 'reset'" });
|
||||
@ -80,6 +78,7 @@ export function createSessionsManageTool(opts?: {
|
||||
cfg,
|
||||
sandboxed: opts?.sandboxed === true,
|
||||
});
|
||||
// TODO: add "manage" to SessionAccessAction for accurate error messages
|
||||
const visibilityGuard = await createSessionVisibilityGuard({
|
||||
action: "send",
|
||||
requesterSessionKey: effectiveRequesterKey,
|
||||
@ -104,10 +103,7 @@ export function createSessionsManageTool(opts?: {
|
||||
kept?: number;
|
||||
}>({
|
||||
method: "sessions.compact",
|
||||
params: {
|
||||
key: resolvedKey,
|
||||
...(instructions ? { instructions } : {}),
|
||||
},
|
||||
params: { key: resolvedKey },
|
||||
});
|
||||
return jsonResult({
|
||||
status: "ok",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user