> 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/authoring-dynamic-behaviors.md). Agents can also search and read this documentation through its [MCP server](https://docs.concurrence.com/~gitbook/mcp).

# Author Dynamic Behaviors

Hypotheses to test when you write dynamic behaviors: conditions the selector can tell apart, short instructions, states, sticky turns, testing, and rollback.

These are hypotheses to test, first on a test service and then against your own callers' wording, not rules. The selector is a model, so what works depends on your wording, your other behaviors, and your Context Graph. Each section says what to try, why the platform's behavior suggests it, and how to check it. [Dynamic Behaviors](https://docs.concurrence.com/agent/context-graphs/dynamic-behaviors) explains how behaviors are chosen and how long they stay, and the [API guide](https://docs.concurrence.com/developer-guide/platform-api/workspaces/dynamic-behaviors.md) covers the operations and limits.

## Two Behaviors to Work With

The sections below use two behaviors for an appointment line.

**Billing questions**

* Condition: The caller has a question about a bill, a balance, a statement or a payment.
* Examples: "Why did I get a bill for my last visit?", "I think I was charged twice", "Can I set up a payment plan?"
* Instruction: Keep answers short and in plain words. Ask which visit or statement the caller means before explaining a charge, and finish by saying what the next step is.

**Appointment changes**

* Condition: The caller wants to move, cancel, or confirm an appointment.
* Examples: "I need to push my Thursday visit", "Can you cancel tomorrow's appointment?", "Is my appointment still on for Monday?"
* Instruction: Confirm which appointment the caller means, repeat the details back before changing anything, and finish by saying what happens next.

## Describe the Situation, Not Keywords

**Hypothesis:** A condition that says what the caller wants or is doing is easier for the selector to match than a list of words.

On each caller turn the selector reads the condition of every behavior offered on that turn beside the conversation, and chooses one behavior or none. There is no keyword or similarity matching ahead of it, so a condition is read as a sentence about the caller. "The caller wants to move, cancel, or confirm an appointment" is likely to give it more to work with than "appointment, reschedule, cancel".

**Test:** Run turns that use none of your keywords, such as "I can't make it Thursday", and check that the behavior still applies.

## Give Examples in the Caller's Words

**Hypothesis:** Examples that read like what callers say help the selector more than rewordings of the condition.

The selector reads examples with the condition. The reply does not read them. Vary the vocabulary and the tone: explicit and implicit requests, calm and distressed callers. Aim for examples that are neither so generic that they fit anything nor so specific that they rarely occur. "Is my appointment still on for Monday?" is more likely to generalize than "Is my 2:30 cleaning on the 3rd still on?". A version holds up to 50 examples. See [Limits](https://docs.concurrence.com/developer-guide/platform-api/workspaces/dynamic-behaviors.md#limits).

**Test:** Write synthetic phrasings that match how your callers talk, without names or other identifying details, and check which behavior applies to each. Compare a general example with a specific one in the same position.

## Put the Clearest Examples First

**Hypothesis:** The first examples carry more weight than the rest.

The selector reads every example. By default, the first three also appear beside the condition in the options it chooses between, and the service can configure this count. A version can hold up to 50, but the clearest few are the ones worth placing first.

**Test:** Move a clearer example to the front, rerun your border-case turns, and compare which behavior applies.

## Keep Neighbors Apart

**Hypothesis:** Behaviors whose conditions rarely fit the same turn are chosen more consistently.

The platform does not compare conditions or examples across sets, and it has no priority field. Where several behaviors fit, the selector is asked to choose the closest one, and also to keep the behavior in force while the topic continues, so overlap makes the result depend on wording and on which behavior was already in force. The checks the platform does make are one pin per set, unique set names, valid state names, and the size budget. "I want to cancel because of a bill" sits between the two behaviors above.

**Test:** Write several turns that sit between two behaviors. Run each more than once from a fresh start, and again right after each neighbor has been applied. If the result varies, sharpen the conditions or merge the two behaviors.

## Name the Set for What It Covers

**Hypothesis:** A clear name helps the selector, and a rename is a change worth testing.

The selector reads the set's name beside the condition, so a name such as "Billing questions" is likely to help and "Behavior 7" to add nothing. The name belongs to the set, not to a version, so a rename reaches every service that pins the set. See [Archive and Restore a Set](https://docs.concurrence.com/developer-guide/platform-api/workspaces/dynamic-behaviors.md#archive-and-restore-a-set). Tags do not reach the selector or the reply, so a priority or category tag has no effect at runtime. Use tags to find sets.

**Test:** Before you rename a set that live callers reach, write the same version into a second set with the name you want, pin that set on a test service, and rerun your border-case turns.

## Write Instructions That Stand Alone

**Hypothesis:** A short instruction that states its own situation is followed more reliably than a long one.

The reply sees only the instruction, not the condition or the examples, so it does not know why the guidance is there. Say when the guidance applies, what to do, and what a good result looks like, in a few sentences. The reply is told that the platform's core instructions, the crisis resource guidance, the empathy priority when it applies, and every action guideline (boundary constraints and guardrails included) take precedence over the instruction, and that the instruction takes precedence over the agent's persona, its behavioral and communication guidance, and progress toward the state's objective. Write it to work inside the guidelines rather than against them. A rule that must outrank this guidance belongs in a boundary constraint or a guardrail in the Context Graph, and guidance for every turn of a state belongs in that state's own guidelines. Boundary constraints and guardrails steer the model and the platform does not enforce them on the reply, so test them, and use tool permissions for a limit the platform must enforce.

**Test:** Read replies on the same turns with the behavior and without it. Check that the guidance shows up, and that nothing in it conflicts with a guideline. In `add` mode the reply is told to follow the guideline.

## Narrow with States

**Hypothesis:** Limiting a behavior to the states where it makes sense reduces matches where it does not.

List the action and data collection states on the pin, or leave `states` empty for every one. Two things to plan for:

* A behavior limited to a state is not offered on the turn that enters it, so put guidance needed on that first turn in the state's own guidelines or in a behavior with no states. See [Limits That Shape Design](https://docs.concurrence.com/agent/context-graphs/dynamic-behaviors#limits-that-shape-design).
* Creating a Context Graph version that has no state a pin names is refused when the version set follows the graph's latest version. To rename or remove a state on such a version set, unpin the set, create the Context Graph version, and then pin again with the renamed states. Clearing the pin's `states` instead makes the behavior apply in every action and data collection state until you pin it again, and a disabled pin is still checked. A version set pinned to a specific graph version is not checked.

**Test:** Walk a conversation across the state boundary, and check the first turn in the state, the turn after it, and the turn that leaves.

## Carry Few Behaviors

**Hypothesis:** A small set of clear behaviors is chosen more reliably than a large one.

On each caller turn the selector reads the conditions and examples of every behavior offered on that turn. The enabled pins of a version set can carry at most 160,000 characters of them, across at most 254 pins. Those are ceilings, not targets. Start with the few situations where guidance changes the outcome, and add one behavior at a time. On text, the reply waits for the choice, so a service with enabled behaviors can take longer to answer.

**Test:** After each addition, rerun your border-case turns and compare reply time on text.

## Choose Sticky Turns for the Minimum Hold

**Hypothesis:** Setting `sticky_turns` to the number of caller turns the guidance must last at least, and leaving the rest to the selector, ends guidance at about the right time.

A higher value keeps guidance in force after the caller's wording drifts, and a lower one lets the selector end it earlier. [How Long a Behavior Stays](https://docs.concurrence.com/agent/context-graphs/dynamic-behaviors#how-long-a-behavior-stays) gives the rule for the minimum and for what ends a behavior after it.

**Test:** Run conversations where the caller changes topic partway through, and check that the behavior ends when you expect.

## Start with Add Mode

**Hypothesis:** Guidance that fits inside the existing action guidelines works in `add` mode, and `replace` mode is worth its cost only where those guidelines would contradict the instruction.

An `admin` or `owner` key writes and pins `replace` mode with the same permissions as `add` mode. See [Permissions](https://docs.concurrence.com/developer-guide/platform-api/workspaces/dynamic-behaviors.md#permissions). Replace mode leaves the reply's action guidelines out and uses your instruction in their place, and [What the Reply Follows](https://docs.concurrence.com/agent/context-graphs/dynamic-behaviors#what-the-reply-follows) lists what stays. It needs an instruction.

**Test:** Run the same turns in both modes and compare replies. If `add` mode already gives the reply you want, keep it.

Do not author emergency handling as a behavior. Once the platform's pattern check recognizes, in English or Spanish, that a caller describes a medical emergency or self-harm, no behavior applies for the rest of the conversation. The check covers a limited set of phrasings and can miss others, and a behavior stays in force on a turn it misses, so a behavior is not where that handling belongs. See [Runtime Safety](https://docs.concurrence.com/operations-and-safety/runtime-safety).

## Measure Before You Write Guidance

**Hypothesis:** A version with a condition and examples but no instruction shows how often a situation arises before any guidance changes a reply.

A version without an instruction can be chosen and is recorded, and it adds no guidance of its own. Pin it, then read `dynamic_behavior` on conversation turns, and `dynamic_behavior_decision` and `triggered_behaviors` on calls, to see how often the situation comes up and whether the selector recognizes it. Read the decisions on the day of the call. See [Read What Applied](https://docs.concurrence.com/developer-guide/platform-api/workspaces/dynamic-behaviors.md#read-what-applied). Then write the next version with an instruction. Because the selector chooses one behavior at a time, an applied behavior without an instruction ends any behavior in force, so measure on a test service or with no other behaviors pinned.

**Test:** Compare the count of turns the selector recognized with the count you expected from a sample of conversations.

## Test on a Test Service Before the Live One <a href="#test-on-a-test-service" id="test-on-a-test-service"></a>

Run a candidate where no live caller reaches it, so wording problems show up before callers meet them.

1. Write the candidate version. It changes nothing until a version set pins it.
2. Pin it on a test service, in a test workspace if you have one, and run conversations through that service. Pins belong to a service, so a pin on the test service changes nothing the live service runs.
3. Decide beforehand how many of the turns that should apply must apply. Try turns that should apply, turns that should not, and turns between two behaviors, and run each more than once. Selection is a model's judgment, so expect some variation, and do not expect a behavior on every matching turn. For repeated runs, launch saved cases against the test service with `service_id`. A simulation runs the service's `release` version set and its results carry no behavior records, so judge it by the replies. See [Simulation Coverage](https://docs.concurrence.com/developer-guide/platform-api/safety/simulation-coverage.md).
4. Read the records from a test conversation or call, not from a simulation. See [Read What Applied](https://docs.concurrence.com/developer-guide/platform-api/workspaces/dynamic-behaviors.md#read-what-applied). A text conversation read returns the behavior each reply used. The choice made on each caller turn, including the turns where nothing applied, is returned on calls.
5. Read the replies against the instruction and the action guidelines, and walk the conversation through the states the behavior is limited to.
6. Pin the same version on the service that takes live traffic, one behavior at a time, so a change in the records points to one cause.

## Roll Back by Moving the Pin

Because versions cannot be edited, a pin change rolls a behavior back without rewriting text:

* Disable the pin with `"enabled": false` to stop the behavior being offered while keeping the pin in place.
* Move the pin back to the earlier version, which reads exactly as it was written.
* Remove the pin to take the behavior off the service. A set can be archived only when no version set pins it.

A rollback takes effect as [Saving a Pin Applies It](https://docs.concurrence.com/developer-guide/platform-api/workspaces/dynamic-behaviors.md#saving-a-pin-applies-it) describes. Check the records after the change. The steps are in [Move, Disable, or Clear a Pin](https://docs.concurrence.com/developer-guide/platform-api/workspaces/dynamic-behaviors.md#move-disable-or-clear-a-pin).

## Related Pages

* [Dynamic Behaviors](https://docs.concurrence.com/agent/context-graphs/dynamic-behaviors) describes how the selector chooses and how long a behavior stays.
* [Dynamic Behaviors API guide](https://docs.concurrence.com/developer-guide/platform-api/workspaces/dynamic-behaviors.md) covers permissions, limits, and errors.
* [Services](https://docs.concurrence.com/developer-guide/platform-api/workspaces/services.md) covers version sets.


---

# 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/authoring-dynamic-behaviors.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.
