Skip to content

Chat API

For the request lifecycle read Chat architecture. Start with installation, then use configuration, client integration and the cookbook. This page contains exact settings, events and Python contracts.

GeneralManager chat exposes selected managers to a tool-capable LLM through HTTP, server-sent events (SSE), or WebSocket. Enable it through GENERAL_MANAGER["CHAT"]; GeneralManager installs the routes during Django application startup.

See Add LLM chat to a GeneralManager project for a complete setup and How LLM chat works for the runtime model.

Settings

The minimal configuration is:

GENERAL_MANAGER = {
    "CHAT": {
        "enabled": True,
        "provider": "general_manager.chat.providers.OllamaProvider",
        "provider_config": {"model": "qwen3.5:9b"},
    }
}

Top-level chat settings

Setting Default Behavior
enabled False Register chat HTTP, SSE, and eligible WebSocket routes at startup.
url "/chat/" Base path used for every chat transport. Leading and trailing slashes are normalized for Django routing.
provider "general_manager.chat.providers.OllamaProvider" Dotted provider class path. The class is constructed without arguments for each HTTP/SSE request or WebSocket connection.
provider_config {} Mapping read by the selected provider. Supported keys depend on the adapter.
provider_profiles {} Optional named provider-profile mappings used by planned roles. Each profile supplies provider, provider_config, and trust_group.
planned {} Planned read-orchestration settings. enabled defaults to True; see Planned read orchestration.
permission None Callable or dotted path receiving (user, scope). Returning False denies the request or socket.
allowed_origins None Explicit WebSocket origin list. When empty, Channels' allowed-host origin validator is used.
allowed_mutations [] Exact generated GraphQL mutation names the mutate tool may execute.
confirm_mutations [] Allowed mutation names that require client confirmation. Every name must also be in allowed_mutations.
confirm_timeout_seconds 30 Lifetime of a pending mutation confirmation.
max_results 200 Maximum query page size accepted by the chat query tool.
query_timeout_seconds None Optional database query timeout in seconds. It is converted to milliseconds for supported database execution.
max_retries_per_message 3 Maximum non-mutation tool-loop retries in one user turn.
max_mutations_per_message 8 Maximum mutation tool executions in one user turn, including a mutation resumed after confirmation. Set 0 to disallow writes for a turn.
max_total_rounds_per_message None Optional positive cap for legacy provider rounds in a turn, including summaries and recovery. When omitted, the cap is max_retries_per_message + max_mutations_per_message + 2. Normal planned reads count rounds without a round cap and retain their stage deadlines.
tool_strategy "discovery" discovery exposes the stable discovery tool set for the retained mutation workflow; direct replaces that set with one query tool per exposed manager. This setting does not select read orchestration.
recover_missing_tool_calls False Add bounded recovery prompts when a model answers without required tools or returns no answer after tools.
system_prompt "" Project-specific instructions appended to the built-in system prompt.
max_recent_messages 20 Recent persisted messages retained verbatim when conversation context is built.
summarize_after 10 Message count after which older history may be summarized by the provider.
ttl_hours 24 Retention threshold used by python manage.py chat_cleanup. Cleanup is not scheduled automatically.

Rate limits

The rate_limit mapping is merged with these defaults:

{
    "requests": 60,
    "window_seconds": 3600,
    "tokens": None,
    "input_tokens": None,
    "output_tokens": None,
}

Positive integer limits are enforced through the Django cache. The scope is the authenticated user ID, then the anonymous session key, then the client IP. None, zero, and negative values do not create a budget for that counter. Provider usage events supply token counts.

Once a token budget is exhausted, GeneralManager records the completed provider usage and rejects the next tool, confirmation write, summary, or provider round. A rate_limited event includes retry_after_seconds.

Planned turns check admission before each planner, executor, and synthesis attempt, including correction and fallback, and before tool dispatch. These checks do not count another user request. Already observed usage is booked once even when parsing, cleanup, a later attempt, or client cancellation fails. Calls already in flight can exceed a limit before their usage becomes known; that usage is still recorded, while newly dispatched work is rejected. A quota denial does not trigger paid synthesis of partial results; committed evidence and usage remain available in the prepared turn's result or interrupted result.

Audit settings

The audit mapping is merged with:

{
    "enabled": False,
    "level": "off",
    "logger": None,
    "max_result_size": 4096,
    "redact_fields": ["password", "secret", "token", "key", "credential"],
}

For WebSocket chat, logger is a callable or dotted callable path receiving one sanitized event mapping. level="messages" emits user and assistant messages; level="all" also emits tool activity. max_result_size truncates serialized tool results. Redaction recursively replaces values whose key contains a configured term. All transports separately expose Django signals for chat activity and errors.

Provider adapters

Provider credentials can be passed in provider_config. When an SDK supports its own environment variables, omitting api_key delegates credential lookup to that SDK. Built-in providers retain zero-argument construction for legacy chat. They also accept an explicit mapping through from_config(config) and expose the copied, read-only mapping through provider_config; planned profile construction uses these two hooks without changing legacy settings.

An explicitly named provider_profiles entry is always constructed with its own provider_config, including {}. It never inherits credentials, model, or endpoint values from the legacy provider_config. Only an omitted provider_profiles mapping creates the implicit legacy profile.

Provider history keeps tool call IDs, names, arguments, and results as structured data. The built-in adapters translate that history to each SDK's native tool-call and tool-result format; custom providers receive it through the Message tool fields.

Timeout enforcement depends on the execution path:

  • The retained mutation/provider loop reads the top-level chat provider_config. There, timeout_seconds (default 60) limits the first provider event, and stream_timeout_seconds (default 30) limits gaps between later events.
  • Planned reads call complete_provider_round() directly. Its timeout covers the whole provider round, including stream consumption and cleanup, within the calling stage's budget. The default shared planning/evidence deadline is 90 seconds; synthesis has a separate 30 seconds. This path does not read stream_timeout_seconds or apply the mutation loop's first-event/stall timers.
  • Separately, Ollama, OpenAI, and Anthropic pass their adapter configuration's timeout_seconds (default 60) to the SDK client. That SDK timeout remains distinct from the planned stage/round deadline. The Gemini adapter does not implement or forward either timeout key internally; its planned reads have the same stage/round boundary, without a general 30-second stream-stall timer.
Provider path Extra Provider configuration
general_manager.chat.providers.OllamaProvider chat-ollama model (default gemma4:e4b), base_url (default http://127.0.0.1:11434), timeout_seconds (default 60)
general_manager.chat.providers.OpenAIProvider chat-openai model (default gpt-4.1-mini), api_key, base_url, timeout_seconds (default 60), structured_outputs (default False)
general_manager.chat.providers.AnthropicProvider chat-anthropic model (default claude-3-5-haiku-latest), api_key, max_tokens (default 1024), timeout_seconds (default 60)
general_manager.chat.providers.GeminiProvider chat-google model (default gemini-2.5-flash), api_key; timeout behavior follows the execution-path distinctions above

GoogleProvider is an alias of GeminiProvider. The OpenAI provider accepts a base_url for OpenAI-compatible services.

Each OpenAI completion owns its SDK client and response stream and closes them on completion, failure, cancellation, or early iterator closure. Client cleanup also runs if creating the response stream fails; cleanup preserves an existing request failure or cancellation.

Optional schema guidance

Planner and synthesis requests can pass their existing response schemas through the optional StructuredOutputProvider.complete_structured(messages, tools, *, response_schema=...) capability in providers.base. Providers implementing only complete(messages, tools) retain that call unchanged. Evidence-executor rounds and the retained mutation loop use the ordinary completion path.

For an OpenAI profile, set provider_config["structured_outputs"] = True to send response_format={"type": "json_schema", "json_schema": {..., "strict": False}}. This is best-effort schema guidance, without a strict schema-adherence guarantee. The original schemas contain conditional rules and optional fields outside OpenAI's strict subset; the adapter preserves them. Use this opt-in only with an endpoint and model supporting the Chat Completions JSON Schema format. OpenAI-compatible endpoints do not necessarily support it. API rejection does not trigger a retry with schema guidance removed.

All existing JSON, plan, choice-source and evidence validators still run. Refusal or incomplete output cannot produce an accepted result; available usage remains accounted for through the normal completion boundary. See the OpenAI schema restrictions before selecting a model. Other built-in adapters currently keep their existing completion behavior.

The configured model must implement structured tool or function calling.

Routes and request contracts

With the default url="/chat/", startup registers three Django routes and one WebSocket route. HTTP views are POST-only and CSRF-protected.

Non-streaming HTTP

POST /chat/
Content-Type: application/json
X-CSRFToken: <token>

{"text": "Which projects use aluminum parts?"}

Successful and tool-level error responses use HTTP 200 with ordered events:

{
  "events": [
    {"type": "text_chunk", "content": "Mercury uses ..."},
    {"type": "done", "usage": {"input_tokens": 100, "output_tokens": 20}}
  ],
  "answer": "Mercury uses ..."
}

answer concatenates all text_chunk.content values. Permission denial uses HTTP 403. This endpoint cannot pause and resume a mutation listed in confirm_mutations; it emits confirmation_required_transport instead.

SSE

POST /chat/stream/
Content-Type: application/json
Accept: text/event-stream
X-CSRFToken: <token>

{"text": "Which projects use aluminum parts?"}

Each event is encoded as data: <JSON>\n\n and the response content type is text/event-stream. Because the endpoint is POST-based, use streaming fetch or an SSE client that supports POST rather than the browser's GET-only EventSource constructor.

The server creates an anonymous session before SSE headers are sent, so the response includes a usable Django session cookie even before its first event. Chat stores a deterministic hash only when a signed-cookie value exceeds the conversation key column limit; the cookie itself is unchanged.

Resolve a pending SSE confirmation through:

POST /chat/confirm/
Content-Type: application/json
X-CSRFToken: <token>

{"confirmation_id": "call-1", "confirmed": true}

The confirmation endpoint returns the same {events, answer} envelope as the non-streaming endpoint and resumes the provider after the tool result.

WebSocket

Connect to /chat/ using ws or wss. The application is wrapped in Channels' AuthMiddlewareStack, so Django session authentication is available as scope["user"].

Send a user message:

{"type": "message", "text": "List all materials"}

Resolve a mutation confirmation:

{
  "type": "confirm",
  "confirmation_id": "call-1",
  "confirmed": true
}

Only one turn and one pending confirmation may be active on a socket. Unknown event types produce bad_event; an overlapping message produces turn_in_progress or confirmation_pending.

Persistent context

Long legacy HTTP, SSE, and WebSocket turns share one bounded-context path. It retains recent messages and summarizes the older prefix using the selected provider's whole-request timeout. A summary records the exact last message it covers; a missing or outdated marker regenerates the summary rather than reusing unknown coverage. Tool windows retain each selected assistant call group and only that group's linked results. Historical rows without a stored call identity are labeled assistant context, never sent as native tool-result messages.

Server event contract

Events arrive in order. Clients should ignore unknown fields so compatible metadata can be added later.

tool_call

The provider requested a server-side tool:

{"type": "tool_call", "id": "call-1", "name": "query", "args": {}}

tool_result

The server validated and executed a tool:

{
  "type": "tool_result",
  "id": "call-1",
  "name": "query",
  "result": {"data": [], "total_count": 0, "has_more": false}
}

text_chunk

One assistant text fragment:

{"type": "text_chunk", "content": "No matching records were found."}

done

The turn is complete:

{
  "type": "done",
  "usage": {"input_tokens": 100, "output_tokens": 20}
}

Usage values depend on the provider SDK and may be zero when the provider does not report them.

confirm_mutation

An allow-listed mutation is waiting for explicit approval:

{
  "type": "confirm_mutation",
  "id": "call-1",
  "mutation": "createPart",
  "input": {"name": "Bolt"}
}

error

A public, non-sensitive failure:

{
  "type": "error",
  "message": "Chat rate limit exceeded. Try again later.",
  "code": "rate_limited",
  "retry_after_seconds": 3600
}

The optional fields depend on code. Unexpected internal exceptions are reported as the generic chat_error event and are emitted through the chat error signal for server-side observability.

Code Transport Meaning and client action
bad_message HTTP, SSE, WebSocket text is absent, blank, or not a string. Correct the payload before retrying.
bad_event Confirmation HTTP, WebSocket The event shape, confirmation payload, or confirmation ID is invalid. Do not retry unchanged.
confirmation_pending WebSocket A new message arrived before the current mutation confirmation was resolved. Resolve or reject it first.
confirmation_unavailable WebSocket Durable confirmation state was already claimed, resolved, or expired. Refresh the conversation state.
turn_in_progress WebSocket Another turn is still streaming on this socket. Wait for its terminal event.
rate_limited HTTP, SSE, WebSocket The actor exceeded a configured budget. Retry after retry_after_seconds.
tool_retry_limit HTTP, SSE, WebSocket The model exceeded max_retries_per_message; the turn is terminal.
mutation_limit HTTP, SSE, WebSocket The turn exhausted max_mutations_per_message; no further mutation is executed.
turn_limit HTTP, SSE, WebSocket The turn exhausted max_total_rounds_per_message; no further provider round is started.
mutation_batch_unsupported HTTP, SSE, WebSocket A completion requested mutate with another tool call. Request one mutation in a completion by itself.
confirmation_required_transport HTTP A confirmed mutation needs SSE or WebSocket. Retry the workflow on a confirmation-capable transport.
chat_error HTTP, SSE, WebSocket An unexpected server or provider failure. Show the generic message and correlate server-side logs or signals.

Permission denial returns HTTP 403 for HTTP/SSE and closes a WebSocket with code 4403. WebSockets recheck the chat permission callable before each new message and positive mutation confirmation. Rejection or confirmation timeout still clears local pending state, but any provider continuation requires renewed chat admission. Native GraphQL permissions remain responsible for data access. A WebSocket startup failure closes with 1011. CSRF rejection and non-POST HTTP methods use Django's standard HTTP 403 and 405 responses before a chat event is produced.

Chat tools

The discovery strategy exposes:

Tool Important inputs Result
search_managers query Matching exposed manager summaries
get_manager_schema manager Fields, filters, descriptions, and relations
find_path from_manager, to_manager Exposed relation path or no path
query manager, filters, fields, limit, offset Bounded GraphQL data page
mutate mutation, input Mutation result, denial, or confirmation requirement

Only managers with chat_exposed = True are accepted. Query fields, nested selections, filters, limits, and offsets are validated against the indexed schema before execution. Mutations require an authenticated user and an exact name in allowed_mutations.

The query tool caps each page at the smaller of positive CHAT.max_results and GRAPHQL_MAX_PAGE_SIZE, including when limit is omitted. Invalid GraphQL pagination configuration is rejected before execution. Offsets retain native paging semantics: the requested window is assembled from at most two bounded pages; the offset never increases pageSize. This bounds fetched rows, not backend work required to locate a deep page or compute a count.

Read-only tool calls may be batched in one provider completion. A completion that includes mutate and any other tool call is rejected before any tool runs; request each mutation by itself so the client-confirmation protocol can retain one pending write safely.

Persistence and cleanup

Chat persistence is installed with the GeneralManager Django migrations:

python manage.py migrate

ChatConversation belongs to an authenticated user or anonymous Django session. ChatMessage records ordered conversation and tool items. ChatPendingConfirmation stores confirmation state, including expiry and resolution metadata, until cleanup removes the record. A successful HTTP or WebSocket confirmation atomically claims the pending record scoped to the current authenticated actor or anonymous session before the server executes the mutation. This prevents durable approval replay across processes when persistence is enabled. When persistence is unavailable, a WebSocket pending confirmation remains owned by that socket session and can be consumed once; it does not provide cross-process replay protection.

Prune stale conversations and resolved or expired confirmations using:

python manage.py chat_cleanup

The command reads ttl_hours. Schedule it with the deployment's normal task runner; GeneralManager does not schedule it automatically.

Signals

general_manager.chat.signals exposes four Django signals for application observability:

Signal Emitted for
chat_message_received An accepted user message with user and conversation context
chat_tool_called A completed server-side tool call with arguments and result
chat_mutation_executed Mutation tool outcomes, including immediate execution and confirmation resolution (execution, rejection, or timeout); inspect result.status
chat_error A transport or provider failure with server-side context

Receivers should avoid raising exceptions; GeneralManager dispatches these signals with Django's robust signal delivery.

general_manager.chat.signals.chat_message_received module-attribute

chat_message_received = Signal()

general_manager.chat.signals.chat_tool_called module-attribute

chat_tool_called = Signal()

general_manager.chat.signals.chat_mutation_executed module-attribute

chat_mutation_executed = Signal()

general_manager.chat.signals.chat_error module-attribute

chat_error = Signal()

Provider protocol

A custom provider class is instantiated without arguments and must implement the asynchronous provider protocol. It receives provider-neutral messages and tool definitions and yields text, tool-call, and terminal events:

from collections.abc import AsyncIterator

from general_manager.chat.providers.base import (
    ChatEvent,
    DoneEvent,
    Message,
    TokenUsage,
    ToolDefinition,
)


class MyProvider:
    async def complete(
        self,
        messages: list[Message],
        tools: list[ToolDefinition],
    ) -> AsyncIterator[ChatEvent]:
        # Adapt the provider SDK's streaming response here.
        yield DoneEvent(usage=TokenUsage())

Yield TextChunkEvent for assistant text and ToolCallEvent with a stable ID, tool name, and decoded argument mapping for tool requests. Finish every normal completion with DoneEvent. A provider may define check_configuration() for startup validation and required_extra for an installation hint.

general_manager.chat.providers.base.BaseLLMProvider

Bases: Protocol

Minimal streaming protocol implemented by chat LLM adapters.

provider_config property

provider_config

Return the read-only configuration used by this provider instance.

from_config classmethod

from_config(config)

Construct a provider using an instance-scoped configuration.

complete

complete(messages, tools)

Stream text, tool calls, and completion metadata for one turn.

general_manager.chat.providers.base.Message dataclass

Provider-neutral chat history, including structured tool exchanges.

general_manager.chat.providers.base.ToolDefinition dataclass

Provider-agnostic tool schema exposed to an LLM provider.

general_manager.chat.providers.base.TextChunkEvent dataclass

Streaming assistant text emitted by a provider.

general_manager.chat.providers.base.ToolCallEvent dataclass

Provider request to execute one configured chat tool.

general_manager.chat.providers.base.DoneEvent dataclass

Terminal provider event carrying optional usage metadata.

general_manager.chat.providers.openai.OpenAIProvider

Bases: BaseLLMProvider

Streaming provider backed by the OpenAI Python SDK.

provider_config property

provider_config

Return the read-only configuration for this provider instance.

__init__

__init__(config=None)

Create a provider with explicit config or legacy chat settings.

from_config classmethod

from_config(config)

Create a provider with a copied profile configuration.

check_configuration classmethod

check_configuration(config=None)

Validate that the OpenAI SDK is available before use.

complete_structured

complete_structured(messages, tools, *, response_schema)

Opt into best-effort schema guidance without changing legacy calls.

complete async

complete(messages, tools, *, response_schema=None)

Stream OpenAI text, tool calls, and usage events for one chat turn.

general_manager.chat.providers.anthropic.AnthropicProvider

Bases: BaseLLMProvider

Streaming provider backed by the Anthropic Python SDK.

provider_config property

provider_config

Return the read-only configuration for this provider instance.

__init__

__init__(config=None)

Create a provider with explicit config or legacy chat settings.

from_config classmethod

from_config(config)

Create a provider with a copied profile configuration.

check_configuration classmethod

check_configuration(config=None)

Validate that the Anthropic SDK is available before use.

complete async

complete(messages, tools)

Stream Anthropic text, tool calls, and usage events for one chat turn.

general_manager.chat.providers.google.GeminiProvider

Bases: BaseLLMProvider

Streaming provider backed by the Google GenAI Python SDK.

provider_config property

provider_config

Return the read-only configuration for this provider instance.

__init__

__init__(config=None)

Create a provider with explicit config or legacy chat settings.

from_config classmethod

from_config(config)

Create a provider with a copied profile configuration.

check_configuration classmethod

check_configuration(config=None)

Validate that the Google GenAI SDK is available before use.

complete async

complete(messages, tools)

Stream Gemini text, tool calls, and usage events for one chat turn.

general_manager.chat.providers.google.GoogleProvider module-attribute

GoogleProvider = GeminiProvider

general_manager.chat.providers.ollama.OllamaProvider

Bases: BaseLLMProvider

Streaming provider backed by the official Ollama Python client.

provider_config property

provider_config

Return the read-only configuration for this provider instance.

__init__

__init__(config=None)

Create a provider with explicit config or legacy chat settings.

from_config classmethod

from_config(config)

Create a provider with a copied profile configuration.

check_configuration classmethod

check_configuration(config=None)

Validate that the Ollama SDK and base URL are usable.

complete async

complete(messages, tools)

Stream Ollama text, tool calls, and usage events for one chat turn.

general_manager.chat.providers.openai.OpenAIDependencyImportError

Bases: ImportError

Raised when the optional OpenAI dependency is unavailable.

general_manager.chat.providers.anthropic.AnthropicDependencyImportError

Bases: ImportError

Raised when the optional Anthropic dependency is unavailable.

general_manager.chat.providers.google.GoogleDependencyImportError

Bases: ImportError

Raised when the optional Google GenAI dependency is unavailable.

general_manager.chat.providers.ollama.OllamaDependencyImportError

Bases: ImportError

Raised when the optional Ollama dependency is unavailable.

general_manager.chat.providers.ollama.OllamaBaseUrlError

Bases: ValueError

Raised when the configured Ollama base URL is unsupported or malformed.

Settings, errors, and audit helpers

general_manager.chat.settings.ChatConfigurationError

Bases: ValueError

Raised when chat settings are invalid.

invalid_settings_mapping classmethod

invalid_settings_mapping()

Build the error for a non-mapping chat settings value.

invalid_permission classmethod

invalid_permission()

Build the error for an invalid chat permission setting.

missing_graphql_schema classmethod

missing_graphql_schema()

Build the error for chat startup without a GraphQL schema.

unknown_allowed_mutations classmethod

unknown_allowed_mutations(names)

Build the error for configured mutations not present in GraphQL.

invalid_confirm_mutations classmethod

invalid_confirm_mutations(names)

Build the error for confirmed mutations not allowed for chat.

invalid_planned_settings classmethod

invalid_planned_settings(detail)

Build an error for invalid planned-chat configuration.

invalid_turn_limit classmethod

invalid_turn_limit(name, expected)

Build the error for an invalid bounded-turn setting.

general_manager.chat.settings.get_chat_settings

get_chat_settings()

Return chat settings merged with defaults.

general_manager.chat.settings.validate_chat_settings

validate_chat_settings()

Validate chat settings and return the normalized configuration.

general_manager.chat.errors.PublicChatError dataclass

Sanitized chat error safe to return to clients.

as_event

as_event()

Render the error as the public chat event payload.

general_manager.chat.errors.public_chat_error

public_chat_error(_exc)

Map an internal exception to a generic public chat error.

general_manager.chat.errors.planned_public_error

planned_public_error(reason)

Map a stable planned terminal reason without exposing internal details.

planned_public_error(reason) accepts only the stable planned reasons listed below. It returns a PublicChatError; invalid or unknown reasons use the generic chat_error code and message. public_chat_error(exc) preserves an exception's valid public_reason, maps a plain TimeoutError to deadline_exceeded, and maps other unexpected exceptions to chat_error.

Code Public message
invalid_plan I could not prepare a safe plan for that request.
manager_unresolved I could not reliably answer that from the available data.
dependency_blocked A required part of the request could not be completed.
budget_exhausted The request reached its execution limit.
deadline_exceeded The request reached its time limit.
provider_failed The provider could not complete the request.
synthesis_failed I could not produce a grounded answer from the available data.

general_manager.chat.audit.planned_audit_lineage_id

planned_audit_lineage_id(value)

Return a deterministic opaque audit identifier for planner-controlled IDs.

general_manager.chat.audit.emit_planned_audit_event

emit_planned_audit_event(event_type, payload, *, sink=None)

Emit only category-approved planned diagnostics through the generic sink.

emit_planned_audit_event(event_type, payload, *, sink=None) accepts only the allowlisted planned event categories. It hashes planner-controlled identifiers and canonical call identities, validates category-specific fields, and drops raw plans, manager names, profiles, trust groups, credentials, results, and exceptions before forwarding to the generic audit sink.

Django system checks

When chat is enabled, python manage.py check can report:

ID Meaning
general_manager.chat.E001 The generated GraphQL schema is not initialized.
general_manager.chat.E002 Chat settings, permissions, or mutation allow-lists are invalid.
general_manager.chat.E003 The selected provider's optional dependency is missing.
general_manager.chat.E004 The provider import failed for another reason.

Installed evaluation CLI

python -m general_manager.chat.evals [OPTIONS]

The module command configures Django, optionally registers a built-in schema fixture, loads packaged YAML datasets, constructs one or more providers, runs the selected cases synchronously, prints a report, and returns no Python value. python -m general_manager.chat.evals --help can run without Django settings; every evaluation run requires either --settings MODULE or a nonempty DJANGO_SETTINGS_MODULE.

Option Value and behavior
--settings Import path for the Django settings module. Overrides an existing DJANGO_SETTINGS_MODULE for this process.
--provider Provider class import path. When omitted, GeneralManager imports the provider configured in GENERAL_MANAGER["CHAT"].
--model Model name merged into the selected provider configuration before provider construction.
--dataset One legacy-compatible packaged dataset name. When omitted, the runner selects all legacy-compatible datasets; planned_orchestration is excluded because it requires deterministic role-pinned providers.
--fixture toy or large; registers the matching built-in eval schema before the run.
--tier Integer tier filter.
--tag Required tag filter; repeat the option to pass multiple tags.
--compare Comma-separated provider class import paths. Runs each provider and prints a comparison report instead of the single-provider report.
--verbose, -v Includes detailed failure information in a single-provider report.
--trace-jsonl File path that receives per-case JSONL traces.

The packaged dataset names are basic_queries, demo_readiness, edge_cases, follow_ups, large_schema, multi_hop, and planned_orchestration. The installed CLI runs the first six through production Planned orchestration; selecting planned_orchestration explicitly is rejected. That packaged dataset is instead exercised by the deterministic planned tests described in the task guide.

Eval exit status

  • Status 0: argument help was displayed, or every selected result passed.
  • Status 1: at least one selected result failed.
  • Status 2: argument parsing failed, including a run without Django settings.
  • Other nonzero termination: Django setup, provider import or construction, fixture registration, dataset loading, trace writing, or evaluation raised an exception.

--settings takes precedence over DJANGO_SETTINGS_MODULE; --provider takes precedence over the configured provider; and --compare takes precedence over single-provider selection.

The installed CLI preserves custom no-argument provider construction, model and provider overrides, comparison, fixture selection, project managers and traces. Its selected provider serves all four planned roles serially through real exposed tools. Evaluation is read-only: mutation plans stop without calling a legacy provider loop. Production mutation permissions and confirmation are unchanged. Each turn permits at most 10 provider dispatches, including planner and synthesis calls; native evidence/synthesis deadlines still apply.

New reports carry chat-evaluation/5. Historical /1, /2, /3 and /4 reports remain readable but cannot be used as comparable baselines for current execution. Contract /5 retains the bounded result-list check and adds separate quantity-prose abstention after a recognized list. The answer keyword score still does not establish factual correctness of every claim; see the packaged check limits. Internal legacy strategy and injected-recovery options are removed; a request cap has the name max_provider_requests, with max_tool_iterations retained only as a per-turn request-cap alias. The two cap names cannot be combined.

Application automation should prefer the module CLI rather than import eval runner internals. See the task guide and command cookbook.

Planned read orchestration

Planner and synthesis share the clarification-topic distinction: criterion asks for the missing standard of an open evaluative judgment; metric asks for the missing measurement of an already defined analysis. They ask only for choices still unresolved by the user or an applicable definition. Once the standard and measurement are supplied, they do not ask for them again. The existing structured question renderer and closed topic vocabulary are unchanged.

All new HTTP, SSE, and WebSocket messages use Planned orchestration. The planner classifies reads and writes before dispatch. Reads have three processing stages: planner, executor, and synthesizer. A shared fallback profile handles recovery under the existing trust and deadline checks; task complexity does not select a provider. A validated mutation plan enters the retained mutation workflow, which keeps its permissions, confirmation, ownership, duplicate, and retry checks. The write provider is constructed only when that workflow needs it.

planned.enabled=False is deprecated: it emits DeprecationWarning and still uses Planned. Invalid settings fail validation rather than selecting an older read loop. The global CHAT.enabled switch still controls whether chat is exposed.

GENERAL_MANAGER = {
    "CHAT": {
        "provider": "myproject.providers.LegacyProvider",
        "provider_config": {},
        "provider_profiles": {
            "fast_local": {
                "provider": "myproject.providers.LocalProvider",
                "provider_config": {"model": "small"},
                "trust_group": "local",
            },
            "strong_local": {
                "provider": "myproject.providers.StrongProvider",
                "provider_config": {"model": "large"},
                "trust_group": "local",
            },
        },
        "planned": {
            "enabled": True,
            "catalog": "myproject.chat.get_manager_catalog",
            "roles": {
                "planner": "strong_local",
                "executor": "strong_local",
                "synthesizer": "strong_local",
                "fallback": "strong_local",
            },
            "max_concurrent_tasks": 3,
            "evidence_timeout_seconds": 90,
            "synthesis_timeout_seconds": 30,
        },
    },
}

The required role names are planner, executor, synthesizer, and fallback. Old role maps must be migrated explicitly: select the desired executor profile and rename the recovery role to fallback. The removed planned.routing.select_executor_role API has no replacement; every task uses executor, subject to recovery. routing_features remains validated descriptive plan metadata and does not select a provider. If provider_profiles is omitted, planned mode creates the implicit default profile from the legacy provider and configuration, assigns every role to it, and uses trust group default. Every profile used by a normal turn must share one trust_group; client HTTP, SSE, and WebSocket payloads cannot choose a profile or trust group. planned.catalog may be a mapping, callable, or dotted callable path. A catalog entry has the exact chat-exposed manager name as its key and domain, aliases, use_when, and distinguish_from fields:

{
    "PartManager": {
        "domain": "manufacturing",
        "aliases": ["part", "component", "item"],
        "use_when": "The question concerns designed or purchased components.",
        "distinguish_from": ["MaterialManager"],
    },
}

Catalog metadata only ranks candidates; it never changes schema visibility, permissions, field access, or query authorization.

Planned mode keeps the normal transport vocabulary. Actual tool events add task_id; final synthesis produces text_chunk; exactly one done reports complete or partial coverage; and an error is terminal only when no grounded answer is available. Stable planned error codes are invalid_plan, manager_unresolved, dependency_blocked, budget_exhausted, deadline_exceeded, provider_failed, and synthesis_failed. Their messages are stable and do not include profiles, trust groups, catalog data, plans, or exceptions. Other exceptions remain the generic chat_error mapping.

Planned audit events use the existing audit setting and are allowlisted before the generic audit sink. They can record deterministic opaque hashes of plan/task lineage, role (never profile), trust-group validation outcome, match-source categories, a SHA-256 canonical call hash, duplicate/progress state, round budgets, latency, reported token usage/cost, evidence-kind counts, coverage, and terminal reason. Raw tool results, manager names, plans, credentials, and exceptions are excluded; the existing configured field redaction and result-size limits still apply to the generic audit layer.

Planned synthesis receives the current request, eligible resolved evidence and a turn-local snapshot of GENERAL_MANAGER["CHAT"]["system_prompt"], when that setting is a nonempty string. Only this configured text is added; generated schema prompts and conversation history are not copied. This preserves existing application definitions across planning, follow-ups and synthesis fallback. Schema field descriptions remain inside their original evidence payloads. Definitions are reference data, not instructions or proof of record values. Their manager and field scope must be respected; missing or conflicting meanings must not be invented. Evidence eligibility, tool permissions and provider limits are unchanged.

Planned settings and catalog

The settings helpers normalize the nested planned mapping into immutable profile and role data. get_planned_chat_settings() always enables Planned reads. All four required roles must resolve to configured profiles, all mapped profiles must share one trust_group, and each configured provider must support the explicit configuration construction used by build_profile_provider().

general_manager.chat.planned.config.REQUIRED_ROLES module-attribute

REQUIRED_ROLES = (
    "planner",
    "executor",
    "synthesizer",
    "fallback",
)

general_manager.chat.planned.config.ProviderProfile dataclass

One configured provider available to planned chat.

general_manager.chat.planned.config.PlannedChatSettings dataclass

Immutable normalized settings used by planned chat.

general_manager.chat.planned.config.get_planned_chat_settings

get_planned_chat_settings()

Return immutable planned-chat settings normalized from chat settings.

general_manager.chat.planned.config.profile_for_role

profile_for_role(settings, role)

Return the configured provider profile assigned to a planned-chat role.

general_manager.chat.planned.config.build_profile_provider

build_profile_provider(profile)

Build a provider from a profile without changing legacy settings.

general_manager.chat.planned.config.validate_profile_provider

validate_profile_provider(profile)

Build a profile provider and run its supported configuration check.

load_manager_catalog(source, schema_index) accepts None, a mapping, a callable, or a dotted callable path. It returns an immutable catalog whose entries contain domain, normalized aliases, use_when, and distinguish_from; a catalog entry for a manager absent from schema_index raises ChatConfigurationError. Catalog metadata ranks candidates but does not change schema exposure or authorization.

general_manager.chat.planned.catalog.ManagerCatalogEntry dataclass

Normalized metadata used to rank one chat-exposed manager.

general_manager.chat.planned.catalog.ManagerCatalog dataclass

Immutable validated catalog and its canonical content fingerprint.

general_manager.chat.planned.catalog.normalize_match_text

normalize_match_text(value)

Normalize free text into comparable case-insensitive words.

general_manager.chat.planned.catalog.load_manager_catalog

load_manager_catalog(source, schema_index)

Load a catalog without changing the live chat schema index.

Validation intentionally trusts only schema_index membership. Catalog metadata can improve ranking, but cannot expose a hidden manager.

Planned task and validation types

Plans are JSON-compatible mappings. validate_plan(payload) returns a frozen ValidatedPlan for one to six read roots, or a mutation plan with no tasks; invalid shapes raise PlanValidationError before application data access. validate_dynamic_children(parent, payload, existing_tasks) validates at most two non-recursive children and enforces globally unique task IDs and compatible dependencies.

general_manager.chat.planned.models.TaskStatus module-attribute

TaskStatus = Literal[
    "pending",
    "running",
    "awaiting_clarification",
    "resolved",
    "blocked",
    "budget_exhausted",
]

general_manager.chat.planned.models.TerminalReason module-attribute

TerminalReason = Literal[
    "invalid_plan",
    "manager_unresolved",
    "dependency_blocked",
    "budget_exhausted",
    "deadline_exceeded",
    "provider_failed",
    "synthesis_failed",
]

general_manager.chat.planned.models.RequirementKind module-attribute

RequirementKind = Literal[
    "schema", "path", "query", "calculation"
]

general_manager.chat.planned.models.RoutingFeature module-attribute

RoutingFeature = Literal[
    "has_dependency",
    "requires_calculation",
    "multiple_queries",
]

general_manager.chat.planned.models.PlanIntent module-attribute

PlanIntent = Literal['read', 'mutation']

general_manager.chat.planned.models.CALCULATION_OPERATIONS module-attribute

CALCULATION_OPERATIONS = (
    "count",
    "sum",
    "average",
    "minimum",
    "maximum",
    "difference",
    "ratio",
    "percentage",
    "multiply",
    "sum_products",
)

general_manager.chat.planned.models.EvidenceRequirement dataclass

One explicit piece of evidence needed to resolve a planned task.

general_manager.chat.planned.models.PlannedTask dataclass

A validated root or bounded dynamic child task.

general_manager.chat.planned.models.ValidatedPlan dataclass

An immutable plan accepted by the planned-chat validator.

general_manager.chat.planned.validation.MAX_ROOT_TASKS module-attribute

MAX_ROOT_TASKS = 6

general_manager.chat.planned.validation.MAX_CHILDREN_PER_ROOT module-attribute

MAX_CHILDREN_PER_ROOT = 2

general_manager.chat.planned.validation.MAX_ROOT_DEPENDENCY_DEPTH module-attribute

MAX_ROOT_DEPENDENCY_DEPTH = 1

general_manager.chat.planned.validation.PlanValidationError

Bases: ValueError

Private validation detail with a stable public invalid_plan reason.

general_manager.chat.planned.validation.validate_plan

validate_plan(payload)

Validate one complete JSON plan before any application data access.

general_manager.chat.planned.validation.validate_dynamic_children

validate_dynamic_children(parent, payload, existing_tasks)

Validate at most two non-recursive children owned by one root.

Planned resolution, evidence, and calculations

ManagerResolver ranks up to five managers that are already present in the schema index. resolve(query, anchors=()) returns deterministic ManagerCandidate records and may use anchors to prefer managers connected by an exposed relation path.

general_manager.chat.planned.resolver.AUDIT_MATCH_SOURCES module-attribute

AUDIT_MATCH_SOURCES = MappingProxyType(
    {
        "exact manager name": "exact_name",
        "exact catalog alias": "exact_alias",
        "catalog domain": "catalog_domain",
        "catalog aliases": "catalog_alias",
        "catalog use_when": "catalog_use_when",
        "schema description": "schema_description",
        "schema fields": "schema_field",
        "schema filters": "schema_filter",
        "schema relations": "schema_relation",
    }
)

general_manager.chat.planned.resolver.ManagerCandidate dataclass

One compact, locally ranked manager candidate.

general_manager.chat.planned.resolver.ManagerResolver

Rank only managers present in the live chat schema index.

resolve

resolve(query, anchors=())

Return up to five candidates in the specified lexicographic order.

EvidenceRecord snapshots JSON payloads and read-only provenance. An EvidenceStore owns turn-local records and links them to compatible EvidenceRequirement objects. canonical_call_identity() produces stable canonical JSON for a tool name and its arguments. calculate_evidence() allows only the operations in CALCULATION_OPERATIONS and returns the derived value as another immutable evidence record. Add that returned record to an EvidenceStore explicitly when it should participate in later requirement resolution; the calculation helper does not persist it itself.

general_manager.chat.planned.evidence.EvidenceError

Bases: ValueError

Base class for invalid evidence or evidence links.

general_manager.chat.planned.evidence.InvalidEvidenceError

Bases: EvidenceError

Raised when an evidence record cannot be represented safely.

general_manager.chat.planned.evidence.DuplicateEvidenceError

Bases: EvidenceError

Raised when a store receives an evidence ID it already contains.

general_manager.chat.planned.evidence.EvidenceNotFoundError

Bases: EvidenceError

Raised when an evidence link references an unknown record.

general_manager.chat.planned.evidence.IncompatibleEvidenceError

Bases: EvidenceError

Raised when a requirement cannot be satisfied by an evidence record.

general_manager.chat.planned.evidence.EvidenceLinkError module-attribute

EvidenceLinkError = IncompatibleEvidenceError

general_manager.chat.planned.evidence.EvidenceKind module-attribute

EvidenceKind = Literal[
    "schema", "path", "query", "calculation"
]

general_manager.chat.planned.evidence.EvidenceRecord dataclass

One immutable snapshot of successful, structured evidence.

create classmethod

create(
    evidence_id,
    task_id,
    kind,
    call_identity,
    provenance,
    payload,
)

Create a record by serializing a detached JSON payload.

payload

payload()

Decode and return a fresh payload snapshot on every access.

general_manager.chat.planned.evidence.EvidenceStore

Turn-local evidence collection with explicit requirement linking.

Records remain in memory until the owning turn ends. Methods return the immutable records they add or link; this store does not persist evidence.

add

add(record, *, requirement=None)

Register immutable history; only explicit capture observations set freshness.

snapshot

snapshot()

Stage an atomic arithmetic batch over the same immutable records.

commit_snapshot

commit_snapshot(staged)

Commit a validated synchronous batch without changing existing records.

is_linked

is_linked(task_id, evidence_id)

Whether this exact record is linked to an admitted task requirement.

observe_schema

observe_schema(task_id, payload)

Observe turn-wide freshness and report any snapshot change.

invalidate_schema

invalidate_schema(task_id, manager)

A failed capture or stale token revokes this manager's turn-wide proof.

schema_observations

schema_observations(task_id, manager)

Current own-task discovery, including observations not yet requirement-linked.

general_manager.chat.planned.evidence.canonical_call_identity

canonical_call_identity(name, args)

Return canonical JSON for one tool name and its JSON arguments.

general_manager.chat.planned.calculations.CalculationError

Bases: ValueError

Raised when a requested calculation cannot be safely evaluated.

general_manager.chat.planned.calculations.CalculationOperand dataclass

A query path or the verified scalar value of derived evidence.

general_manager.chat.planned.calculations.calculate

calculate(operation, operands)

Evaluate explicit numeric operations; units require separate source proofs.

general_manager.chat.planned.calculations.calculate_evidence

calculate_evidence(
    evidence_id,
    task_id,
    operation,
    operands,
    store,
    *,
    provenance=None,
    call_identity=None,
    require_linked=False,
    binding=None
)

Compute from task-owned queries or transitively verified calculations.

The scheduler requires every source to be linked to a declared requirement. Standalone callers may compute before linking, but task ownership is mandatory.

Unit declarations

Interface.field_unit_contracts accepts immutable declarations from FieldUnitContract. The declarations are validated against the existing interface attributes when the executable schema is built; they describe dimensions and do not provide values or conversion data.

general_manager.interface.unit_contract.FieldUnitContract dataclass

Immutable application declaration, never inferred from row unit strings.

FieldUnitContract.fixed_quantity(*, unit: str, label: str) -> FieldUnitContract declares a known fixed quantity unit for a numeric interface attribute that has no sibling unit field. unit must be a supported non-offset unit and label must be non-empty; invalid or unknown units, offset units, or empty labels raise ValueError during construction. Applying the contract to a missing or non-numeric target attribute is rejected during executable schema validation. The returned contract is immutable and takes effect after the schema is rebuilt.

Planned orchestration helpers

The lower-level planned modules are transport-neutral and are useful when an application owns a custom chat transport or deterministic test harness. Normal applications should configure CHAT["planned"] and use the existing transport routes. plan_request() performs at most one correction and one fallback attempt; complete_provider_round() accepts exactly one terminal DoneEvent and either text or ordered tool calls with unique IDs; synthesize_answer() references only eligible resolved evidence. ProviderRoundResult.tool_calls contains every accepted call in order. Its original three positional arguments and tool_call accessor remain supported; tool_call is the first call or None for a text response.

general_manager.chat.planned.budget.RoundBudget

Track every planned provider request in one global ledger.

Global-only calls (planner and synthesizer) use :meth:consume_global. Executor calls use :meth:consume_subtree, which atomically charges both the global and owning-root ledgers.

Direct construction retains its historical limits. Normal planned turns use enforce_limits=False to count rounds without an admission cap. None means unbounded; callers may still assign explicit numeric limits.

consume_global

consume_global()

Charge one planner/synthesizer request to the global budget.

consume_subtree

consume_subtree(root_id)

Charge one executor request globally and to its owning root.

consume

consume(root_id=None)

Charge one request, using global-only or executor semantics.

Normal planned-turn factories use RoundBudget(root_ids, enforce_limits=False). Counts remain integers; unbounded limits and remaining values are None. Direct RoundBudget(root_ids) construction preserves the historical admission limits for existing callers. Explicit numeric global_limit and subtree_limit values remain enforceable in either mode.

general_manager.chat.planned.budget.RoundBudgetExhausted

Bases: RuntimeError

Raised when a provider request would exceed a hard round limit.

general_manager.chat.planned.budget.BudgetExhaustedError module-attribute

BudgetExhaustedError = RoundBudgetExhausted

general_manager.chat.planned.planner.InvalidPlanError

Bases: ValueError

Stable terminal failure for an unusable planner result.

general_manager.chat.planned.planner.PlanningResult dataclass

A validated plan and all known usage from its provider attempts.

general_manager.chat.planned.planner.plan_request async

plan_request(
    user_text,
    messages,
    settings,
    budget,
    catalog_summary,
    *,
    configured_context=None,
    on_usage=None,
    before_attempt=None
)

Request, correct once, then fall back once to a validated plan.

general_manager.chat.planned.provider_calls.InvalidProviderRoundError

Bases: ValueError

Raised when a provider stream cannot represent one planned round.

general_manager.chat.planned.provider_calls.ProviderRoundResult dataclass

The only valid outcomes of one planned provider request.

general_manager.chat.planned.provider_calls.complete_provider_round async

complete_provider_round(
    provider,
    messages,
    tools,
    timeout_seconds,
    *,
    classify_provider_errors=False,
    on_usage=None,
    response_schema=None
)

Buffer one bounded provider stream without changing legacy iteration.

Planned orchestration accepts either text or ordered tool calls, never both. The timeout is supplied by the calling stage after it caps the request to its remaining deadline.

general_manager.chat.planned.synthesis.SynthesisFailedError

Bases: ValueError

Stable terminal failure when no grounded synthesis is available.

general_manager.chat.planned.synthesis.SynthesisResult dataclass

One grounded answer and its eligible evidence references.

general_manager.chat.planned.synthesis.synthesize_answer async

synthesize_answer(
    user_text,
    resolved_evidence,
    coverage,
    settings,
    budget,
    *,
    configured_context="",
    conversation_context=(),
    task_context=(),
    choice_context=None,
    on_usage=None,
    before_attempt=None
)

Return one grounded answer, then use the fallback profile exactly once.

general_manager.chat.planned.events.PLANNED_PUBLIC_MESSAGES module-attribute

PLANNED_PUBLIC_MESSAGES = {
    "invalid_plan": "I could not prepare a safe plan for that request.",
    "manager_unresolved": "I could not reliably answer that from the available data.",
    "dependency_blocked": "A required part of the request could not be completed.",
    "budget_exhausted": "The request reached its execution limit.",
    "deadline_exceeded": "The request reached its time limit.",
    "provider_failed": "The provider could not complete the request.",
    "synthesis_failed": "I could not produce a grounded answer from the available data.",
    "rate_limited": "Chat rate limit exceeded. Try again later.",
}

general_manager.chat.planned.events.planned_done_event

planned_done_event(usage, *, resolved, total, unresolved)

Build the sole terminal event for a grounded complete or partial turn.

general_manager.chat.planned.events.planned_error_event

planned_error_event(reason)

Build the sole terminal event when no grounded answer exists.

general_manager.chat.planned.events.planned_tool_call_event

planned_tool_call_event(task_id, call_id, name, args)

Build an actual planned tool-call event with its owning task ID.

general_manager.chat.planned.events.planned_tool_result_event

planned_tool_result_event(task_id, call_id, name, result)

Build the matching actual planned tool-result event.

general_manager.chat.planned.scheduler.SchedulerCallbacks dataclass

Existing chat integration seams, replaceable in deterministic tests.

general_manager.chat.planned.scheduler.PlannedCoverage dataclass

Sanitized resolved/unresolved task coverage for synthesis and done.

general_manager.chat.planned.scheduler.PlannedExecutionResult dataclass

Private completed turn state; it never becomes a public event directly.

general_manager.chat.planned.scheduler.PreparedPlannedTurn dataclass

Planner output plus accounting retained through Task 7 mutation fallback.

mutation_plan property

mutation_plan

Expose the original mutation plan for Task 7's unchanged legacy path.

general_manager.chat.planned.scheduler.prepare_planned_turn async

prepare_planned_turn(
    user_text,
    messages,
    settings,
    catalog_summary,
    *,
    planner=plan_request,
    resolver=None,
    clock=None,
    callbacks=None,
    scope=None
)

Plan once and preserve all planner usage for later terminal accounting.

general_manager.chat.planned.scheduler.iter_planned_read_events async

iter_planned_read_events(
    prepared,
    *,
    scope,
    conversation,
    messages,
    callbacks=None,
    clock=None
)

Yield planned public events, ending in one done or one error.

This accepts only validated read plans. Task 7 reads mutation_plan and sends it through its untouched legacy loop before this iterator is entered.

GraphQL-native read contract (version 2)

At the root, query.fields selects row fields directly, for example ["code"]. The adapter adds the root items and pageInfo wrapper. Nested collection selections still include their advertised items/pageInfo paths.

Read tools now use the exact executable GraphQL names. get_manager_schema returns contract_version: 2, valid roots, scalar fields, directed relations (including wrapper paths), root arguments, and named types with nullability, defaults and input shapes. Domain manager names remain stable identifiers for discovery and provenance. The runtime schema supplies all executable names; no Python spelling aliases are accepted.

For example, use isActive, densityGCm3, shippedAt_Gte or an explicitly customized field name exactly as returned by schema discovery. A former is_active field request must be migrated, unless that is the actual GraphQL name in a schema configured without automatic camel casing. Filtering likewise uses the actual input object, including its declared relation depth. Relation filters for managers without chat_exposed = True are omitted from discovery and rejected before execution, including nested arguments and effective input defaults. This chat boundary does not change public GraphQL permissions.

{
  "manager": "Project",
  "filters": {"customer": {"code": "C01"}},
  "fields": [
    "code",
    {
      "field": "materialsList",
      "arguments": {"pageSize": 10},
      "fields": [{"items": ["code", "name"]}, {"pageInfo": ["totalCount"]}]
    }
  ]
}

The example requires those fields to be exposed by the application's schema. Use root when a manager has several advertised roots. Optional arguments contains exact root arguments, such as orderBy, page, or includeInactive only when advertised. filters is a convenience input for the actual filter argument (including its explicit custom name) and cannot also be provided in arguments. limit and offset retain their tool pagination semantics; when specifying a native page greater than one, its page size must be explicit or resolvable from the schema or configured cap. Native argument defaults are preserved before caps and coverage calculations, at both root and nested pages. Nested selections support scalar names, {fieldName: [fields]}, and {field, arguments, fields}. Output keys retain their GraphQL names.

The response retains data, total_count and has_more, and adds complete. has_more refers to the root page; complete describes whether this response contains the full root result and complete selected nested pages. Missing nested page totals cannot establish completeness. Partial responses remain usable for bounded questions; exhaustive questions need all relevant pages. Configured result caps also clamp supported nested pages.

find_path returns directed executable selection paths, including items for page wrappers. It does not invent reverse edges. Inspect another manager when a schema detail marks its output as a reference. Discovery and both transports' planner payloads remain compact; expanded schema types are loaded on demand. Provider-body admission guards are independently configured by the provider or experiment and are not a production chat setting.

Version 2 currently supports exposed manager roots returning generated pages, object/leaf selections and typed arguments. Unions, interfaces, fragments, arbitrary roots and Python aliases are unsupported. The read compiler uses GraphQL ASTs and typed variables and executes existing resolvers with the same request context and deadlines. Schema validation errors are actionable executor feedback, not evidence. Other backend errors retain their generic public error. REST serialization and mutation inputs/confirmation rules are unchanged. Existing Python callers of the read tools must migrate their requested names explicitly; there is no silent legacy conversion.

Structured clarification responses contain only clarification.language (de, en, fr) and a nonempty unique clarification.requirements list drawn from criterion, metric, horizon, population, customer_identity, record_selector, unit, forecast_method, future_pricing, and reporting_currency. The runtime renders fixed questions; this branch accepts no free answer text, result claims, entity names, numbers, or evidence IDs. The existing read plan must still resolve schema/identity evidence. Data answers continue to require nonempty unique eligible evidence_ids; mixed answers and questions use that grounded branch. The normal fallback, delivery, and persistence paths apply to both response shapes.

Deferred calculation binding validation

A deferred bind_calculation action is validated against concrete, same-task source evidence before the binding becomes immutable. Each declared source must already be linked to its requirement. Root query populations must be complete; value paths must select numeric scalars and grouping/unit paths must be compatible. A relation's items array is not a scalar, even when it contains one row. Query the related manager as the root population instead. Derived bindings require recomputed, compatible predecessor calculations. Failed admission leaves the requirement unbound so the executor can correct its query or binding.

Rejected root query bindings now report each linked query evidence ID and its reproduced source error, alongside the attempted value, grouping and unit paths. Observed scalar paths come only from mappings in that source's actual root rows; collections are never flattened and no field is inferred from schemas or prose. The listed non-null scalar paths are present in every observed row. They describe observed structure, not numeric suitability or a suggested binding. Heterogeneous paths are counted separately; foreign and unlinked evidence is excluded. Observations are bounded to 64 scalar paths, depth 16 and 4096 visited nodes per row, with an explicit observation truncation marker. The existing 1024-character feedback limit and truncated flag still apply. Diagnostics neither select a source nor repair a binding, and the original admission validator is unchanged. Unsupported diagnostic contexts retain their previous error message.

The executor's last_tool_round context reports whether the previous tool round actually added evidence or requirement links. A valid repeated query or unchanged schema observation can return evidence_or_links_changed=false; this is workflow feedback, not an error or a completion certificate. The executor can inspect the current requirements and deferred calculations, gather missing fields, filters or pages, or bind and execute a calculation from verified sources. Cached results can still link another requirement, and schema reads still recheck current snapshots without a cache shortcut. This feedback does not alter validation-cycle identity, timeouts, evidence coverage or native GraphQL permissions.

A successful schema inspection can still be incompatible with its selected requirement. The executor's schema_link_feedback reports the latest such observation for each explicitly named requirement, with its exact evidence ID. Compare the declared scope in task.requirements with the unchanged observation in task_evidence: manager, view, type names and snapshot. The actual selection stays in internal tool history; it is excluded from backend arguments and cache keys. Repeating an incompatible detail inspection with the same requirement_id cannot satisfy an overview requirement. Choose an explicitly compatible inspection under the existing contract or block when required proof cannot be gathered. This feedback neither changes schema requirements nor links incompatible evidence, and does not introduce a full-schema fallback. Compatible detail fragments retain their existing coverage and freshness checks.

Shared read guidance follows the observed GraphQL input scalar: Date uses YYYY-MM-DD, while DateTime uses an ISO 8601 timestamp. Describing a calendar interval in UTC does not change a Date filter into a DateTime filter.

Repeated validation failures terminate only when the same normalized action and feedback recur against unchanged structured task, dependency and evidence inputs, after that feedback was supplied in a completed provider round. Corrected actions, changed evidence and successful operations permit continued work. Diagnosed action cycles carry reason_origin=scheduler_validation_cycle and a validation_cycle proof containing the first, feedback-delivery and repeated pass numbers plus hashes of action, feedback and evidence state. Audit records contain no raw input payloads. Transport exceptions retain their separate origin and are not validation cycles.

Schema transport projection

Explicitly bound schema values use gm.schema-data/3; bound executor/judge whole references use gm.reference-data/2, and synthesis uses its own ownership-bound gm.reference-data/3. Earlier decoders retain their versioned instructions. Selection compares the whole escaped message and keeps the original when the encoding would grow it. Complete reconstruction and source bindings are checked before dispatch; projection changes no exposure, evidence link or permission.

See reference-data transport for formats, Python defaults, historical origin proof, failure semantics and measurement boundaries. This codec is separate from selective schema inspection.

Completed task context for synthesis

The synthesizer also receives the objectives, requirement descriptions and completion criteria of resolved root tasks. These are the actual runtime tasks, including valid changes made during execution. Each requirement lists only selected evidence records linked to it by EvidenceStore.for_requirement(); evidence names are not used to infer links. Synthesis eligibility filtering still applies. Query restrictions and completeness remain in the original call identity and payload rather than a second interpretation.

This versioned internal context describes planner intent and runtime work. A planner assumption is not user consent, and completed coverage does not establish an unambiguous user scope. Visible user messages and the existing application context retain their roles. No authoritative open-decision state is invented, and no new clarification admission gate is introduced. Both supported response branches and the bounded fallback retain their existing behavior.

HTTP, SSE and WebSocket answers do not automatically append this context, task lists, completion criteria or internal evidence IDs. The model may use relevant substantive details in its answer. This is a context improvement, not a proven fix for any particular model response; live effectiveness remains unmeasured.

For an explicitly requested derived forecast or scenario, synthesis should explain the supported method, training coverage and available formula or coefficients. It should disclose assumptions needed to extend the result, including stable definitions and units when applicable, and explain whether external demand, capacity or prices enter the calculation. Unknown input coverage remains uncertain. Historical extrapolation and sensitivity scenarios do not establish causal demand predictions or statistical confidence. These instructions do not supply missing coefficients, history, inputs or evidence.

Snapshot-bound schema inspection (protocol 3)

The public get_manager_schema tool, including Python calls through execute_chat_tool, defaults to view="overview". It returns exact executable root argument signatures and defaults, output field signatures, relations and type_manifest. Inspection protocol 3 includes only direct signature references and visible relation manager references in the overview manifest. Transitive input graphs are discovered from each subsequent detail manifest. Responses carry inspection_version=3, and snapshot preimages bind projection version 3; old version-2 snapshot tokens require fresh observation. The manifest reports input/object/enum/scalar definitions, related manager references, or unsupported types. It does not recursively expand fields or enum values. The full Python inspection APIs manager_schema(manager), get_manager_schema_summary(manager) and tools.get_manager_schema(manager) retain full output by default for compatibility. For the last helper, use an explicit view keyword to request a tagged selective view.

overview = execute_chat_tool("get_manager_schema", {"manager": "Part"}, context)
# Choose these names from this observed type_manifest; never guess generated names.
needed = [name for name, info in overview["type_manifest"].items()
          if info["kind"] in {"input", "enum"}]
details = execute_chat_tool("get_manager_schema", {
    "manager": "Part", "view": "detail", "types": needed,
    "snapshot": overview["snapshot"],
}, context)

Detail requires a nonempty distinct list of exact reachable names and that manager's snapshot. It returns each selected direct definition exactly as in the full exposure-filtered GraphQL contract, without recursive expansion. It also returns the selected definitions and their immediately referenced types in type_manifest. Load further referenced definitions by these newly observed names at the same manager snapshot. A manager reference is a boundary: inspect its target manager's own overview and snapshot before requesting its fields. Unions/interfaces/fragments remain unsupported. Full inspection is available only by explicit view="full"; invalid or stale selectors return an atomic error without partial definitions or automatic full fallback. Hidden managers return no schema. Default, enum and exposure changes invalidate detail tokens. Every inspection captures the current compiled schema contract and records its observation; it is never served from the turn cache. Compiled definitions remain immutable until an explicit schema rebuild.

Planned schema requirements may declare schema={"manager": "Part", "view": "detail", "types": ["observedType"], "snapshot": "current"}. current binds to the latest successful schema capture across all tasks in the current turn for this manager; a literal digest binds exactly that snapshot and must still be current. Overview/full bindings use types=[]. Detail fragments become completion proof only when all required types are covered at one current snapshot, and the completion selection must include that full coverage. A full view can satisfy narrower scopes; detail cannot satisfy overview. Snapshot mismatch or hidden-manager feedback invalidates old proof until fresh observation. Requirements with no schema binding retain full-inspection semantics. Prose descriptions never select scope.

schema_complete means a full contract was returned; query.complete describes data population coverage. Selective projection intentionally does not round-trip to the full schema. The v24 reference codec remains the separate lossless codec.

Planned category reads retain code="invalid_category_binding" when evidence or a filter binding is invalid. Known public contract failures also carry a stable reason:

  • schema_evidence_not_linked: the same-task schema observation has no link to a declared schema requirement. Use a compatible linked inspection; repeating an incompatible detail selector does not create that link.
  • filter_input_definition_not_observed: the selected schema proof does not contain the current executable filter input definitions.
  • invalid_filter_path: a binding path must include filters or the actual arguments/filter-argument prefix before its selectors.

A linked overview can support a complete unfiltered category lookup. A later business filter also needs the observed output and input definitions. An explicit full inspection can satisfy an overview requirement; this is not an automatic fallback. These reasons are operational feedback, never query evidence or completion authority. Unknown, wrong-task and wrong-kind sources retain generic rejection. All permission, exposure, freshness, population and typed-value checks still apply.

The next executor request retains category_lookup, category_bindings, and explicit requirement_id selections in its native tool history. These scheduler arguments never enter backend dispatch or the backend cache identity. category_lookups is private operational feedback referencing the exact linked query and its current manager/schema snapshot. It distinguishes a partial lookup (gather_complete_lookup) from a complete population (bind_business_query) and lists current linked schema inspections for that same snapshot. The executor must still select observed category values, inspect any missing output/input definitions, issue the bound business query, and satisfy all task requirements before completion. After a verified bound query, feedback references its actual business evidence. Partial business populations require gather_complete_business_query; complete results lead to check_requirements_and_complete, which still requires all missing evidence, calculations, and strict completion validation. A later complete business observation replaces earlier partial windows in this feedback only when its manager, exposed root, filters, non-pagination arguments, exact field projection, and before/after schema witnesses match. Native pagination arguments are identified by their exposed resolver roles. Different populations retain their own missing-row work; a later partial observation requires gathering again. Field-list order is compared exactly. Stored evidence remains unchanged. Empty populations retain unresolved-category handling. Stale or hidden lookup sources receive no ready feedback. Cached reads and new requirement links remain valid; this feedback adds no round cap, automatic query, or completion authority.

Measure complete discovery → details → query exchanges, including cumulative request characters, when comparing model input size.

PreparedPlannedTurn.cancellation_observations retains private local cancellation events: requested identifies an actual scheduler cancel call at the evidence deadline, runner cleanup, or event-stream cleanup; observed identifies the executor provider-round boundary that received cancellation. Each event carries the evidence deadline and observation time on the scheduler's monotonic clock, plus its task ID when applicable. Cleanup observations do not identify an unknown outer caller or prove that a provider completed remotely. No cancellation text or provider payload is copied into these events, and they are not emitted as public chat events. If the event iterator is interrupted, interrupted_result retains committed evidence, usage, and last known task states after cleanup. A task can still have a last known running state in this diagnostic snapshot; it has no successful completion claim. The normal result remains None and cancellation still propagates without retry.

The lossless reference codec also applies to synthesis. It selects only schema payloads from eligible resolved evidence and schema history with verified stored tool origins. Each occurrence retains its own evidence, task, call and provenance binding. The original reference, query results, history text and completed task context reconstruct exactly; schema descriptions remain data without instruction authority. Synthesis keeps its RESOLVED_REFERENCE_DATA= prefix. The internal codec helper still defaults to REFERENCE_DATA= for planner/executor callers; tool defaults and the production synthesis timeout of 30 seconds are unchanged.

Rejected planned complete actions retain strict evidence selection and requirement coverage. unsatisfied_requirements feedback names uncovered requirement IDs and, for a bound grouped reduction, the source query ID and missing or duplicate groups. The groups come from the verified selected query population and declared binding; nested relations and business descriptions do not define a different population. Invalid or forged selected evidence receives no coverage claim. Diagnostic text uses the existing 1024-character bound and explicitly marks truncation. Gather or select the missing evidence before completing; repeated identical rejected actions after delivered feedback retain the scheduler's validation-cycle stop.