# How a turn works: Every turn: a decision, an action, an outcome.

Each message opens a turn with a decision: commit, defer or refuse. Your AI does the work and closes the turn with what really happened. Every step leaves a record you can read.

Source: https://www.matterspace.ai/duplex/docs/turns

## For agents

### Without hooks: two calls every turn
1. **Open:** `duplex_context {message}` with the user's latest message word for word (their words, never a tool result).
   - `commit`: reply with Duplex's answer.
   - `refuse`: decline and name the deciding rule from `ruled_by`. Do not report an outcome for work you never did.
   - `defer`: do the work yourself with the context returned. If it gives a route, call that tool. If it gives `use`/`first`, check the inputs match what the user gave before calling.
2. **Close:** `duplex_observe {turn, answer, tools, outcome}` before you reply. `answer` is a one-line summary. `outcome` is `succeeded` only when something checked it worked; otherwise `failed` or `abandoned`. Put things the user explicitly asked to keep in `remember`.

### With hooks
Context arrives on its own in `<duplex_context>`, `<duplex_answer>` and `<duplex_session>`. Each turn is recorded for you. Do not call `duplex_context` or `duplex_observe` on every turn. When a tool call is refused, name the rule and never look for a way around it. A step waiting for approval waits for a person: never approve it yourself.

### Reading the guarantee
`advisory` means rules hold only as far as you follow them. `hooked` means the client checks supported events before they run. Report the guarantee from the record of the specific action.

### If the report is held
Keep the same turn. Read which rule met which part of your report, fix the report to what was really observed, and resubmit. If the work failed, say so and why.

### Lost replies and retries
Put an `operation` ID on writes. If a reply is lost, check `duplex_status {show: "operation"}` before sending again. Never open a new turn for work that already has one.

### Handing over
Pass IDs: task ID, thread ID, skill ID, source and version. Never pass a paraphrase as if it were the record.

Where to find more in the MatterSpace Duplex docs:
- How a turn works, this topic in full: https://www.matterspace.ai/duplex/docs/turns.md
- Every prompt, and where to paste the standing ones: https://www.matterspace.ai/duplex/docs/prompts.md
- Exact tools, operations, settings and answers: https://www.matterspace.ai/duplex/docs/reference.md
- Errors and what to do about them: https://www.matterspace.ai/duplex/docs/troubleshooting.md
- Every docs page, with what it covers: https://www.matterspace.ai/duplex/docs/llms.txt

## For people

### Your AI joins the two ends of a turn

At the start, your original message decides which rules and earlier work apply. At the end, the report records what actually happened. In between, your AI can read a document, run a tool, ask you to decide or return an answer the evidence already supports.

Your latest message reaches Duplex in your own words. If you write “Prepare the draft and show it to me before sending” and your AI shortened it to “prepare the message”, your condition would be lost. Passing it word for word keeps it.

### The three opening decisions

| Decision | What your AI does |
| --- | --- |
| commit | Strong, consistent evidence and current rules support a reusable answer, and Duplex returns it. Ask which examples support it and under what condition it applies. |
| defer | The work is your AI’s. It gets the relevant documents, notes, conflicting examples or an offered action to help it, plus the reason: too little evidence, a disagreement, or a task that belongs with the agent. |
| refuse | The reply names the deciding rule and why. No outcome is reported for work that never happened, and the refusal stays in the audit trail. |

### Read the opening answer

| Field | How to read it |
| --- | --- |
| ruled_by | Every rule that matched, and the one that decided first. Reading only the last name can mislead. |
| practice | Your scope’s declared way of working: the order or style to follow. A declared practice is not an executed tool. |
| use / first | A ready-made call for a particular skill or world. Check it uses the inputs or starting state you gave. |
| available | A capability that fits the request. More input or authority may be needed. It is not a receipt. |
| nearest / floor | The closest lesson and the bar it would have to clear. A near record can be visible while the turn still goes to your AI: decide whether clearer wording or a new lesson would help. |

### What each connection guarantees

Every record says how it was checked. Read it from the record of the action, not from yesterday’s.

Identity, scope, write permission, license limits, rule approval and search allowances are always checked by the service itself. Nothing an assistant writes can change those checks.

To rely on a rule that stops a tool before it runs, check three things: does your client send a pre-run event for that tool, does the event reach the right person’s scope, and was the decision applied to that call?

| Guarantee | What it gives you |
| --- | --- |
| advisory | MCP alone. Your AI asks Duplex for context and reports the outcome. Duplex sees what your AI sends, and your AI keeps control of its other actions. |
| hooked | MCP with client hooks. Your client reports session starts, tool calls and results on its own, and a tool check can stop an action before it runs where the client supports that event. |
| gated | A model gateway. Model calls travel through Duplex, which handles authorization and the outbound call. A separate operating mode. |

### What hook events tell you

| Event | What the record shows |
| --- | --- |
| Session start | Standing instructions and permitted context can reach your client. A resumed session gets its thread’s pack, so your AI knows where it left off. |
| Your prompt | A known decision, guidance or a refusal comes back in the form your client accepts. |
| Before a tool call | An active rule can stop the call. If a person must approve, check which action the approval covers. |
| After a tool call | Success, failure or an edit. A later success does not turn an earlier failure into a success. |
| End of session | The thread can be captured, prepared for compaction or closed. Keep the ID of anything you mean to reopen. |

### From offered, to used, to done

To know whether a method helps, look past how often it was offered.

| Stage | The question it answers |
| --- | --- |
| Offered | Did your AI get a ready call, with a skill ID matched to the request? A general capability list doesn’t count. |
| Used | Did your AI actually make that call? Work done with a different tool is not reuse. |
| Outcome | Succeeded, failed or abandoned? With no report, completion stays unknown. |

### Close the turn honestly

At the close your AI attaches a one-line account of its answer, the tools it really used and the outcome. A tool returning is not the job being done: if the file was made but the check never ran, the report keeps that gap. Succeeded means something checked it worked.

| What happened | How to carry on |
| --- | --- |
| The report was held | A rule caught something in the report and nothing was learned from it yet. Go back to the named rule, keep what was really observed, and if the work failed, report the failure and why. |
| The reply never arrived | Keep the turn or operation ID. If its status shows it completed, read the result; a new turn would create a second record of the same work. |
| Long-running work | Keep the turn ID and report the outcome when it’s known, even much later. Making the text a reusable approved answer may need separate confirmation. |
| Two clients at once | Match owners, tasks and operations by ID. Follow the retry guidance on a busy answer, and check the first request before writing again. |

### The twelve names in your AI’s activity

These are the families of calls your AI makes. It picks the right one for each request; what it may choose depends on its identity and connection.

| Name | What to look for |
| --- | --- |
| duplex_context | The turn opened with your message: its ID, decision, reason and selected sources. |
| duplex_observe | The report of the turn: tools used, outcome, and anything you asked to remember. |
| duplex_learn | What was taught: a label, fact, document, transition, correction, outcome, recipe, skill or environment. |
| duplex_rules | Active rules, proposals awaiting approval, and rule or calling changes you authorized. |
| duplex_task | A task’s objective, steps, checkpoints, checks and closure, and procedures drawn from it. |
| duplex_plan | Next-state readings, simulations, routes, recommended actions, classifications and agreement across phrasings. |
| duplex_skill | Program search and checks, long jobs, runs of kept versions, certificates, reusable parts and search allowances. |
| duplex_tool | A registered tool’s inputs, its actual output or error, and the receipt. |
| duplex_share | A thread’s summary or events, and who it is shared with, how far and for how long. |
| duplex_forget | What was taken out of use, and its restoration where supported. |
| duplex_status | Capabilities, effective settings, audit, certificates, kept methods, full sources and the status of a write or job. |
| duplex_report_feedback | A preview of a report in your own words, where it goes, and confirmation once you approve. |

[Full reference](https://www.matterspace.ai/duplex/docs/reference#tools)

### What to pass when you switch agents

“Continue yesterday’s work” can mean three different things. Hand over the object the next agent needs.

| Hand over | What the next agent can do |
| --- | --- |
| Task ID | Read the goal, what is still owed and the last checked stage, then record the next step on the same job. |
| Thread or share | Read the conversation and where it came from, within the share. Changing the task needs write access to it. |
| Skill ID | Open the method’s card and run it on fresh inputs. A restricted skill needs access under the agent’s own identity. |
| Source and version | Compare an earlier conclusion with the material itself, through your organization’s normal access. |

## Prompts

### Why did Duplex decide that? (ask your AI)

```text
For the last turn, show me Duplex's decision (commit, defer or refuse), the reason, every rule that matched and the one that decided, and the nearest lesson it considered. Quote the record; don't summarize from memory.

Where to find more in the MatterSpace Duplex docs:
- How a turn works, this topic in full: https://www.matterspace.ai/duplex/docs/turns.md
- Every prompt, and where to paste the standing ones: https://www.matterspace.ai/duplex/docs/prompts.md
- Exact tools, operations, settings and answers: https://www.matterspace.ai/duplex/docs/reference.md
- Errors and what to do about them: https://www.matterspace.ai/duplex/docs/troubleshooting.md
- Every docs page, with what it covers: https://www.matterspace.ai/duplex/docs/llms.txt
```

### Report the outcome properly (agent instructions)

```text
Before every reply, close the Duplex turn with duplex_observe: the turn ID from duplex_context, a one-line summary of your answer, the tools you actually used, and the outcome. Use "succeeded" only when a check confirmed the result; otherwise "failed" or "abandoned". If a tool returned but the requested check didn't run, say so in the summary.

Where to find more in the MatterSpace Duplex docs:
- How a turn works, this topic in full: https://www.matterspace.ai/duplex/docs/turns.md
- Every prompt, and where to paste the standing ones: https://www.matterspace.ai/duplex/docs/prompts.md
- Exact tools, operations, settings and answers: https://www.matterspace.ai/duplex/docs/reference.md
- Errors and what to do about them: https://www.matterspace.ai/duplex/docs/troubleshooting.md
- Every docs page, with what it covers: https://www.matterspace.ai/duplex/docs/llms.txt
```

### Prepare a handover for another agent (ask your AI)

```text
I'm handing this work to another agent. List what it needs from Duplex: the task ID, any thread or share, the skill IDs it should run, and the sources with versions. For each, say what the next agent can do with it and what access it needs.

Where to find more in the MatterSpace Duplex docs:
- How a turn works, this topic in full: https://www.matterspace.ai/duplex/docs/turns.md
- Every prompt, and where to paste the standing ones: https://www.matterspace.ai/duplex/docs/prompts.md
- Exact tools, operations, settings and answers: https://www.matterspace.ai/duplex/docs/reference.md
- Errors and what to do about them: https://www.matterspace.ai/duplex/docs/troubleshooting.md
- Every docs page, with what it covers: https://www.matterspace.ai/duplex/docs/llms.txt
```

### Is this step really checked? (ask your AI)

```text
For the tool call you just made, read the Duplex record and tell me its guarantee: advisory or hooked. Did a rule check the call before it ran, and what was the decision?

Where to find more in the MatterSpace Duplex docs:
- How a turn works, this topic in full: https://www.matterspace.ai/duplex/docs/turns.md
- Every prompt, and where to paste the standing ones: https://www.matterspace.ai/duplex/docs/prompts.md
- Exact tools, operations, settings and answers: https://www.matterspace.ai/duplex/docs/reference.md
- Errors and what to do about them: https://www.matterspace.ai/duplex/docs/troubleshooting.md
- Every docs page, with what it covers: https://www.matterspace.ai/duplex/docs/llms.txt
```
