Контекстные политики

Policies контролируют действия агента: tool calls, model requests, file ops и другие операции. Решение принимается в момент действия: ALLOW, ASK или DENY.

Почему contextual

Обычные static rules проверяют только текущий запрос. Policies в Goalrail могут хранить state на протяжении session: накопленные расходы, количество tool calls, risk score, data labels и другие counters.

Это позволяет выражать правила, которые prompt alone не удержит:

Уровни применения

LevelScopeКак добавить
SessionТолько текущая sessionПопросить агента или включить в UI
Agent configКаждый запуск этого агентаpolicies block в YAML
Server-wideВсе sessions на serverServer config или REST API

Session-level policy

Самый простой путь - попросить агента обычным языком:

Ask me before running any shell commands.
Limit this session to $5 of model spend.
Block access to all GitHub repos except myorg/frontend.

Goalrail подберет policy из registry, покажет параметры и попросит подтверждение.

YAML config

policies:
  approve_file_ops:
    type: function
    handler: goalrail.policies.builtins.safety.ask_on_os_tools
  rate_limit:
    type: function
    handler: goalrail.policies.builtins.safety.max_tool_calls_per_session
    factory_params:
      limit: 50

Server-wide config

policies:
  session_cost_guard:
    type: function
    function:
      path: goalrail.policies.builtins.cost.cost_budget
      arguments:
        ask_thresholds_usd: [1.0]
        max_cost_usd: 5.0

Запустите server с config:

goalrail server -c config.yaml

Дальше