Skip to Content

Editing the draft

How PATCH /v1/agents/{id}/draft works — merge-patch semantics, how to clear a value, size limits, and where every settings field is documented.

Every agent setting is written through PATCH /v1/agents/{id}/draft, then promoted and deployed (Agents). This page covers write semantics; the fields live in the map below.

curl -X PATCH https://api.kejue.co/v1/agents/AGENT_ID/draft \
  -H "Authorization: Bearer $KEJUE_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
    "prompt": "Collect the policy number before incident details.",
    "behavior": {
      "guardrails": {"guardrail_set_ids": ["GUARDRAIL_SET_ID"]}
    }
  }'

Merge-patch semantics

The draft patch is a merge patch at the top level only: omitted top-level fields keep their values; an empty object body is a successful no-op (updated: false). Nested objects are not merged — behavior replaces the complete behavior document, so read the draft first and resend every block you keep.

Clearing is explicit and field-dependent:

You sendEffect
Field omittedCurrent value preserved
{} as the whole bodyNo-op; updated: false
promptReplaces the prompt; cannot be blank
behavior: {...}Replaces the whole object; omitted blocks reset to documented defaults. behavior: {} resets everything and removes all assignments.
"" on a model/voice reference (llm_provider_model_id, stt_provider_model_id, tts_provider_model_id, tts_voice_id, speechlm_provider_model_id)Clears the selection
null on those referencesRejected — 422 validation_failed, field code invalid_type. null never clears.
"" on stt_languageClears the fixed language
{} on tts_voice_settingsClears the per-agent voice override

Limits and validation

prompt ≤ 500,000 characters; behavior and tts_voice_settings ≤ 1 MiB each. Validation failures return 422 validation_failed with exact field paths in error.details.fields; the draft is never partially changed. Draft patches need no idempotency key — retries are safe.

The legacy storage fields model_config and stt_hints are not public and are rejected as unknown fields. behavior is closed too: unknown fields error instead of being silently dropped.

Where the fields live

PageCovers
Speech & turn-takingPipeline mode, endpointing, transcription language, models and voice, voice settings, turn taking, background noise
Conversation behaviorTemperature, opening, connection wait, recording, inactivity, memory, resume
Transfers & call actionsSystem tools (transfers, scheduling, end call), tool/MCP, guardrail, and pronunciation assignments, transfer records
Prompt variablesEverything the prompt can reference
GuardrailsAuthoring guardrail sets
PronunciationAuthoring pronunciation tables
Voices & modelsThe catalog the model/voice reference fields point into

See also

Agents · API reference

On this page