Skip to content

Interactions

An interaction is the thing you actually run. It names the agents taking part, the task they work on, the inputs the task needs, and optionally the tools available, the shape of the answer and the limits on time.

Starting an interaction creates a run with an id. When the run finishes, the answer is in its output.

See it in tutorial 1, Hello, agent, which runs the smallest interaction there is, and tutorial 2, Prompts and inputs, which passes values into the task.

KindFolderWho takes partUse it for
One-shotinteractions/one-shot/one agenta question, a task, an extraction: one answer
Round-robininteractions/round-robin/agents (and optionally a person) taking turnschats, debates, reviews
Managedinteractions/managed/a manager agent and the team it hands work towork that splits into parts

Most things start as a one-shot. Round-robin and managed interactions are covered in Teams of agents and, for chatting with a person, in tutorial 7.

interactions/one-shot/haiku.mtr
agent = {
name = "Poet"
agent = @ref("poet")
}
task = @prompt("haiku-task")
inputs.prompts = [
{
name = "topic"
description = "What the haiku is about"
required = true
},
{
name = "mood"
description = "Optional mood, for example calm or playful"
required = false
}
]

agent is the seat: the name the agent goes by in this interaction, and which agent fills it.

Inputs are like function parameters. Declare them under inputs.prompts and use them in the task as %%name%%.

FieldMeaning
namehow the task refers to it: %%topic%%
descriptionshown in the portal and to callers
requireda run without it is refused before it starts, with api:interactions:input-required
typeString (the default), Integer, Decimal or Boolean

Names are case-sensitive. A run that passes an input the interaction doesn’t declare is refused too (api:interactions:input-unknown), and so is a value that isn’t of the input’s type (api:interactions:input-invalid). Nothing is spent on a refused run.

The task can also include text only when an input has a value:

prompts/haiku-task.md
Write a haiku about %%topic%%.
{{#if mood}}
The mood of the haiku should be %%mood%%.
{{/if}}

{{#if mood}} is true when mood has any value at all, so a Boolean input set to false still counts. Use {{#unless name}} for the opposite.

Two more kinds of input feed tools instead of the task. The model never sees either, so it can’t change them:

KindDeclared underThe run’s value
A bindinginputs.functions.bindinggoes straight into a tool’s calls, as a body field or a query or path parameter: the knowledge base to search, say. See values from the run
A secretinputs.functions.authis the id of the secret a tool sends, such as one API key per shop. See secrets chosen by the run

A run passes all three kinds the same way, by name. Unlike a prompt input, a tool input can have a default, which a run that leaves it out uses.

const run = await mt.interactions.run("haiku", { inputs: { topic: "autumn rain", mood: "calm" } });
console.log(run.output);

The SDKs’ run() starts the run and waits for it. With curl you get the new run straight back, with status New, and fetch it again until it finishes: see Runs and events.

StatusMeaning
Newaccepted, waiting for a worker (or for a free lane: see Limits)
Runningworking
HumanInteractionRequiredwaiting for a person to say something. After three days with no message the run is closed as Finished; a message sent later opens it again (Limits)
HumanInteractionCompletea person has replied, and the run is waiting for a worker to carry on
PendingApprovalwaiting for a person to approve a tool call
AwaitingChildrenwaiting for sub-interactions it started
Finisheddone: the answer is in output
Errorfailed, or ran out of time: the reason is in failureDetails
Killedstopped by someone, or because the run that started it was stopped

See them in tutorial 4, Runs: start a run without waiting, read it back, and watch its status change.

Every message a person adds to a chat is saved with an author, a name and an id, and the agents see the name with the message (Ana (Human User): …). Who the author is depends on how the caller signs in:

The caller signs in withThe message is recorded as
an API key, naming no authorthe API key’s own user
an API key, naming an authorexactly that name and id
a person’s own sign-in (the portal, or mt api-login user)always that person; a named author is ignored

So an app that talks to Maitento for its users, with one API key, can say which of its users wrote each message. The id is the app’s own, any GUID; an author named without an id is recorded with an id of all zeros. See it in tutorial 7, A chat.

PropertyWhat it does
functions.openApitools available to every agent in the interaction
schema.solutionthe JSON Schema the answer must match: see Structured output
duration.warn, duration.maxa time warning for the agents and a hard stop, as "hh:mm:ss". See Limits
contexthow the conversation is trimmed when it no longer fits the model. See Limits
loomlong-term memory
swarmother interactions this one may start as sub-runs
prompts.systemextra system instructions for every agent in the interaction