tools, static fn ($tool): bool => $tool instanceof Tool && !$tool->readOnly); if ($writes === []) { return $request; } $common = array_filter($writes, static fn (Tool $tool): bool => $tool->autoApprovable) !== []; $instruction = match ($mode) { PermissionMode::FULL => 'Permission mode: Full. You may use offered undoable write tools without a separate approval when policy allows. Site-content guardrails, the person\'s WordPress permissions and all other policy rules still apply; tools without undo are never available. Explain each change clearly.', PermissionMode::AUTO => $common ? 'Permission mode: Auto. Only offered tools explicitly marked common may run without a separate approval; other writes require approval. Site-content guardrails still require approval. Explain each change clearly.' : 'Permission mode: Auto. No offered write tool is marked common for automatic approval, so every write requires approval. Site-content guardrails still apply.', default => 'Permission mode: Ask. Every model-initiated write requires approval for its exact arguments. Explain the intended change before requesting approval.', }; $system = rtrim($request->system) . "\n\n" . $instruction; return new ModelRequest($system, $request->messages, $request->tools, $request->model, $request->maxTokens, $request->stats); } }