> For the complete documentation index, see [llms.txt](https://docs.concurrence.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.concurrence.com/developer-guide/platform-api/workspaces/direct-programs.md).

# Direct Programs

Create an agent version that runs a direct program, bind it to a service with no Context Graph, and read the refusals a save or a session start returns.

An agent version carries a `program`, which says what a service runs when it selects that version:

* `workflow` - the Context Graph the service binds. A version created without a `program` field is a workflow version.
* `direct` - the version's own `instructions` and the `tools` they are granted, with no Context Graph.

A session on a direct program loads no Context Graph. It runs on text conversations and, for voice, on `grok_voice` app voice sessions and Playground and test calls. A phone call to a service whose version set runs a direct program takes the safe exit, with code `direct_program_phone_line` on a `grok_voice` service (`direct_program_released_harness` when its voice harness is a registered release). For the concept and its trade-offs, read [Direct Programs](https://docs.concurrence.com/agent/direct-programs).

## Before You Start

* A workspace credential that can create agents, agent versions, and services. Use a test workspace with synthetic data.
* For the TypeScript examples, `@amigo-ai/platform-sdk` 0.148.0 or later, whose types include `program` and accept a service without `context_graph_id`. See [Installation](https://docs.concurrence.com/developer-guide/platform-api/platform-sdk/installation.md).
* The tools the program grants, already defined in the workspace. Saving a version does not check that a `tool_id` names one.

Create and revise direct programs through the Platform API or the SDK. The Developer Console shows an agent version's program, with its instructions and tool count, and shows and configures a service that binds no Context Graph. It can duplicate a service that binds no Context Graph, and the copy starts inactive. It has no form that creates a direct program, or that creates a service with no Context Graph from scratch. Agent Forge's `forge platform service create` flags and `forge platform push` create services that bind a Context Graph.

## Create a Direct Agent Version

{% openapi src="<https://platform.api-us.concurrence.com/v1/openapi.json>" path="/v1/{workspace\_id}/agents/{agent\_id}/versions" method="post" %}
<https://platform.api-us.concurrence.com/v1/openapi.json>
{% endopenapi %}

Send `program` with `kind: "direct"` when you create the version:

{% tabs %}
{% tab title="curl" %}

```bash
curl -X POST "https://platform.api-us.concurrence.com/v1/{workspace_id}/agents/{agent_id}/versions" \
  -H "Authorization: Bearer <api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Opening hours assistant",
    "identity": {
      "name": "Opening hours assistant",
      "role": "Answer questions about opening hours in a synthetic exercise.",
      "developed_by": "Example implementation team",
      "default_spoken_language": "English"
    },
    "program": {
      "kind": "direct",
      "instructions": "You answer questions about the opening hours of the Example Clinic test site. Keep each answer to two sentences. Do not ask for patient information. Say that you cannot help with anything other than opening hours.",
      "tools": []
    }
  }'
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import { AmigoClient } from '@amigo-ai/platform-sdk'

const client = new AmigoClient({
  apiKey: process.env.AMIGO_API_KEY!,
  workspaceId: process.env.AMIGO_WORKSPACE_ID!,
  baseUrl: process.env.AMIGO_BASE_URL!,
})

const agent = await client.agents.create({
  name: 'opening-hours-direct',
  description: 'Synthetic direct program exercise',
})

const version = await client.agents.createVersion(agent.id, {
  name: 'Opening hours assistant',
  identity: {
    name: 'Opening hours assistant',
    role: 'Answer questions about opening hours in a synthetic exercise.',
    developed_by: 'Example implementation team',
    default_spoken_language: 'English',
  },
  program: {
    kind: 'direct',
    instructions:
      'You answer questions about the opening hours of the Example Clinic test site. Keep each answer to two sentences. Do not ask for patient information. Say that you cannot help with anything other than opening hours.',
    tools: [],
  },
})

console.log(version.version, version.program.kind) // 1 'direct'
```

{% endtab %}
{% endtabs %}

What the fields mean for a direct program:

* **`program.instructions`** is the authored prompt, 1 to 32,000 characters and not blank. It is stored as written and the model receives it as written.
* **`program.tools`** holds up to 100 tool call specifications, the same `ToolCallSpec` an action state lists, with one entry for each `tool_id`. A `tool_id` listed twice, a spec that sets `navigate_on_completion`, or an unknown field in `program` returns `422`.
* **`name` and `identity`** are still required. The version's `background`, `behaviors`, and `communication_patterns` are not added to a direct program's instructions, so write the role, scope, and boundaries into `instructions`. `identity.default_spoken_language` still applies to the platform's own lines, such as the emergency script, and on a voice call to the language the model is told to speak.
* **Every version response returns `program`**, with `kind` `workflow` for a version that runs its service's Context Graph.

Each version is a full snapshot. A new version does not inherit the previous version's program: a version created without `program` is a workflow version.

A tool spec grants one tool and can bind its parameters to start-time conversation context, as a state's tool spec does. See [Pass Context to Tool Parameters](https://docs.concurrence.com/developer-guide/guides/conversation-context.md) for `context_bindings` and `context_binding_aliases`:

```json
{
  "kind": "direct",
  "instructions": "Look up opening hours with the tool before you state them.",
  "tools": [
    {
      "tool_id": "lookup_test_hours",
      "context_bindings": ["region"]
    }
  ]
}
```

{% hint style="warning" %}
A version set that leaves `agent_version_number` unset follows the agent's latest version. Creating a direct version changes what such a version set runs, on a service that binds a Context Graph too: its sessions run the direct program and read no graph. A voice service on a family other than `grok_voice` can then stop taking calls. Pin `agent_version_number` on every service that uses the agent before you add a direct version to it.
{% endhint %}

## Create a Service That Runs It

{% openapi src="<https://platform.api-us.concurrence.com/v1/openapi.json>" path="/v1/{workspace\_id}/services" method="post" %}
<https://platform.api-us.concurrence.com/v1/openapi.json>
{% endopenapi %}

Leave out `context_graph_id`, or send `null`, and pin the direct version in `release`:

{% tabs %}
{% tab title="curl" %}

```bash
curl -X POST "https://platform.api-us.concurrence.com/v1/{workspace_id}/services" \
  -H "Authorization: Bearer <api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Opening hours chat",
    "agent_id": "{agent_id}",
    "channel_type": "text",
    "version_sets": {
      "release": { "agent_version_number": 1 }
    }
  }'
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
const service = await client.services.create({
  name: 'Opening hours chat',
  agent_id: agent.id,
  channel_type: 'text',
  version_sets: {
    release: { agent_version_number: version.version },
  },
})

console.log(service.context_graph_id) // null
```

{% endtab %}
{% endtabs %}

A service created this way binds no Context Graph, and every read of it returns `context_graph_id: null`. Each of its version sets must:

* Leave `context_graph_version_number` unset.
* Run an agent version whose program is direct: the version it pins, or the agent's latest version when `agent_version_number` is unset.

When `version_sets` is omitted, the API creates an unpinned `release`, which follows the agent's latest version. Pin `agent_version_number` so a later version cannot change what the service runs.

An update keeps the stored binding when `context_graph_id` is omitted or `null`. Setting it to one of the workspace's Context Graphs binds that graph, and the service can then run workflow versions. An update cannot remove a binding. A service that binds a Context Graph also runs a direct program for any version set whose agent version is direct: the stored graph and its version pin are not read for those sessions.

### Save Refusals

A save that would leave a service with no Context Graph running a workflow version returns `422` with `detail.code` `context_graph_required`. The check runs on service create and update, on a [version set upsert](https://docs.concurrence.com/developer-guide/platform-api/workspaces/services.md#upsert-a-version-set), and on agent version create. A [service plan](https://docs.concurrence.com/developer-guide/platform-api/workspaces/services.md#plan-a-service-save) lists it in `problems` with `where` naming `context_graph_id` and the version set. Show `detail.message` to the person who made the save:

| When                                                                        | `detail.message`                                                                                                                                                                                                                                                                                                |
| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A version set pins a Context Graph version                                  | Version set 'release' pins context graph version 3, and the service has no context graph. Set context\_graph\_id, or clear the pin.                                                                                                                                                                             |
| The agent has no version                                                    | Version set 'release' has no agent version to run, so nothing says it runs a direct program. Set context\_graph\_id, or create an agent version that runs a direct program first.                                                                                                                               |
| A version set runs a workflow version                                       | Version set 'release' runs agent version 2, which runs the service's context graph, and the service has none. Set context\_graph\_id, or run an agent version whose program is direct.                                                                                                                          |
| A new workflow version would be followed by a service with no Context Graph | This version runs its service's context graph, and these services have none while a version set of theirs follows this agent's latest version: 'Opening hours chat' ('release'). Give this version a direct program, pin those version sets to a direct version, or set the services' context\_graph\_id first. |

The names and numbers in each message are the request's own. A pin to an agent version that does not exist returns `404` before this check.

## Text Conversations

A direct program runs on every text conversation path. Text conversations load the `release` version set, so `release` must run the direct version. [Create a conversation](https://docs.concurrence.com/developer-guide/platform-api/conversations.md#create-a-conversation) and [send turns](https://docs.concurrence.com/developer-guide/platform-api/conversations.md#send-a-turn) as for any service. The reply comes from the version set's `engage` model preference, or the platform default model. A direct program has no navigation step.

The platform composes its own guidance after your instructions and does not edit them. It also runs these controls around the model:

* **Emergency floor.** Each user message is read before the model sees it, under the service's `emergency_floor` settings, as on a Context Graph conversation. When the floor answers, its script is the reply in place of the model's.
* **Crisis and untrusted-content guidance.** The model receives the region's crisis guidance and, when the program grants tools, the rule that tool results are untrusted content.
* **Dynamic behaviors.** Enabled [dynamic behaviors](https://docs.concurrence.com/developer-guide/platform-api/workspaces/dynamic-behaviors.md#pin-a-version-on-a-service) that the version set pins are chosen on each user turn, and the chosen behavior's instruction is added after yours. A direct program has no states, so leave a pin's `states` empty: on a service with no Context Graph, a save refuses a pin that names one.
* **Tool authorization.** The model is offered the granted tools the conversation has, with bound parameters hidden. On a service that verifies callers, it is also offered the caller-verification tool when a granted tool reads a patient record. Each call is held to the same server-side checks as a tool bound in a Context Graph state, including caller verification before a patient-record read. A tool the program does not grant does not run.
* **Reply check.** When `output_checks.unbacked_action_claims` is `log` or `enforce` for the service, each reply is read before it is delivered, so a streamed turn sends the reply after the check. With `enforce`, a claim that no tool call in the turn backs is cut and replaced with a correction.
* **Platform context.** Context that the platform injects into the conversation is added after your instructions, labelled with its source. A user message or a tool result is not treated as that kind of context.

A turn on a conversation whose saved configuration cannot run returns `422`. Its `detail` is a list with one problem: `type` is the code, `loc` is `["service", "configuration"]`, and `msg` is `The service's saved configuration cannot run on a text session`.

| `type`                                | Cause                                                                                                                      | What to do                                                                                                                            |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `direct_tool_needs_approval`          | A granted tool waits for a reviewer's approval, such as an endpoint under an approval policy or an approval-required skill | Remove the tool from the program, or run it from a Context Graph workflow, where a text conversation can hold the call for a decision |
| `direct_tool_unregistered`            | A granted `tool_id` names no tool the conversation has                                                                     | Correct the `tool_id` in a new version, or define the tool                                                                            |
| `direct_behavior_replaces_guidelines` | An enabled pinned dynamic behavior is in `replace` mode, which replaces a state's action guidelines                        | Disable or unpin it, or pin a behavior in `add` mode                                                                                  |

## Grok Voice

Among the voice families, only `grok_voice` runs a direct program. Select it on the service, with the direct version pinned as above:

```json
{
  "name": "Opening hours voice",
  "agent_id": "{agent_id}",
  "channel_type": "voice",
  "voice_config": { "session_provider": "grok_voice" },
  "version_sets": {
    "release": { "agent_version_number": 1 }
  }
}
```

A direct program's voice call runs on [app voice sessions](https://docs.concurrence.com/developer-guide/guides/app-voice-session.md) and on Playground and test calls. The platform still plays the opening AI and recording notice, runs the emergency scripts and the service's reply checks, and offers the call controls beside the granted tools. The family's own requirements in [Grok Voice](https://docs.concurrence.com/developer-guide/platform-api/workspaces/voice-configuration.md#grok-voice) still apply: a workspace without regional data residency, no enabled dynamic behavior pins, `warm_transfer: false`, and no `filler_vocabulary` or `progress_vocabulary`.

A save that pairs a direct program with `eleven_realtime` returns `422` with `detail.code` `voice_family_direct_program`, a `detail.message` that names the family, and `detail.fields`. A save on another family can succeed, so a successful save does not establish that a call starts. These refusals are made when the call starts:

| Code                              | Cause                                                                                                                                                                                                                          |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `direct_program_unsupported`      | The service's voice family is not `grok_voice`                                                                                                                                                                                 |
| `direct_program_phone_line`       | The call is on a phone line                                                                                                                                                                                                    |
| `direct_program_released_harness` | The call's voice harness is a registered release, from a [harness pin](https://docs.concurrence.com/developer-guide/platform-api/workspaces/services.md#set-harness-pins) or the harness default, and not the built-in harness |
| `direct_voice_tool_undeclared`    | A granted tool is not available to the call                                                                                                                                                                                    |

Where the refusal appears depends on the channel:

* **App voice session.** [Start a Session](https://docs.concurrence.com/developer-guide/guides/app-voice-session.md#start-a-session) returns `422` with `detail.code` `direct_program_unsupported` for a service on another family. The other refusals are made after the socket opens: the app receives an `error` frame with code `service_not_ready`, then `ended`, and the socket closes with `4200`. The frame does not carry the refusal code.
* **Playground and test calls.** The socket closes with `4200`, and the close reason starts with the refusal code. A test call that carries conversation context can report one error that asks you to start a new test call instead. See [Test Call Error Reporting](https://docs.concurrence.com/testing/testing/playground#test-call-error-reporting). Use a Playground voice call to find out why an app session did not start.
* **Phone.** A phone call to the service takes the [safe exit](https://docs.concurrence.com/developer-guide/platform-api/conversations/voice-agent.md#graceful-degradation), with code `direct_program_phone_line` on a `grok_voice` service (`direct_program_released_harness` when its voice harness is a registered release).

## Verify What Ran

1. Read the agent version and confirm `program.kind` is `direct`.
2. Read the service and confirm `context_graph_id` is `null` and `release` pins the version.
3. Run a test conversation, then read its [run](https://docs.concurrence.com/developer-guide/platform-api/conversations/runs.md#what-ran-a-run). `manifest.program_kind` is `direct`, `manifest.program_digest` is a `sha256:` digest of the saved program, and the manifest's Context Graph id and version are null. Two runs with the same digest ran the same instructions and tool specs.

## Limits

* **No Context Graph features.** A direct program has no states, exits, navigation, or state-bound tools. Tools are granted once for the whole conversation.
* **Voice coverage.** `grok_voice` app voice sessions and Playground and test calls only. A phone call to the service takes the safe exit, with code `direct_program_phone_line` on a `grok_voice` service (`direct_program_released_harness` when its voice harness is a registered release). Every other voice family runs a Context Graph.
* **Approval-gated tools.** A direct program does not hold a tool call for a reviewer's decision. A text conversation whose program grants such a tool is refused with `direct_tool_needs_approval`.
* **Context Graph reads.** [Preview Rendered Service Instructions](https://docs.concurrence.com/developer-guide/platform-api/workspaces/services.md#preview-rendered-service-instructions) and [Harness Context](https://docs.concurrence.com/developer-guide/platform-api/functions/harness-context.md) return `409` with `The service's agent version runs a direct program, which has no context graph` for a version set that runs one.
* **Simulations are text.** A simulation runs a conversation as text and opens no voice session, so it is not evidence about a `grok_voice` call. Use a Playground voice call for that. See [Voice Simulation](https://docs.concurrence.com/testing/testing/voice-simulation).
* **Model guidance, not control.** Instructions steer the model and do not make its output deterministic. Enforce permissions and external changes with tool authorization, validation, and approval policy.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.concurrence.com/developer-guide/platform-api/workspaces/direct-programs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
