OSS-first docs
These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.
Starts a new agent run with the given input.
Goal
Execute an AI agent with user input.
Context
Called from chat interface or API.
Source Definition
import {
defineCommand,
defineQuery,
} from '@lssm-tech/lib.contracts-spec/operations';
import { defineSchemaModel, ScalarTypeEnum } from '@lssm-tech/lib.schema';
import { GranularityEnum, LogLevelEnum, RunStatusEnum } from './run.enum';
import {
RunInputModel,
RunLogModel,
RunModel,
RunStepModel,
RunSummaryModel,
TimelineDataPointModel,
} from './run.schema';
export const ExecuteAgentCommand = defineCommand({
meta: {
key: 'agent.run.execute',
version: '1.0.0',
stability: 'stable',
owners: ['@agent-console-team'],
tags: ['run', 'execute'],
description: 'Starts a new agent run with the given input.',
goal: 'Execute an AI agent with user input.',
context: 'Called from chat interface or API.',
},
io: {
input: defineSchemaModel({
name: 'ExecuteAgentInput',
fields: {
agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
input: { type: RunInputModel, isOptional: false },
sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
metadata: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
stream: { type: ScalarTypeEnum.Boolean(), isOptional: true },
maxIterations: {
type: ScalarTypeEnum.Int_unsecure(),
isOptional: true,
},
timeoutMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
},
}),
output: defineSchemaModel({
name: 'ExecuteAgentOutput',
fields: {
runId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
status: { type: RunStatusEnum, isOptional: false },
estimatedWaitMs: {
type: ScalarTypeEnum.Int_unsecure(),
isOptional: true,
},
},
}),
errors: {
AGENT_NOT_FOUND: {
description: 'The specified agent does not exist',
http: 404,
gqlCode: 'AGENT_NOT_FOUND',
when: 'Agent ID is invalid',
},
AGENT_NOT_ACTIVE: {
description: 'The specified agent is not active',
http: 400,
gqlCode: 'AGENT_NOT_ACTIVE',
when: 'Agent is in draft/paused/archived state',
},
},
},
policy: { auth: 'user' },
sideEffects: {
emits: [
{
key: 'run.started',
version: '1.0.0',
stability: 'stable',
owners: ['@agent-console-team'],
tags: ['run', 'started'],
when: 'Run is queued',
payload: RunSummaryModel,
},
],
audit: ['run.started'],
},
acceptance: {
scenarios: [
{
key: 'execute-agent-happy-path',
given: ['Agent exists', 'Agent is active'],
when: ['User submits execution request'],
then: ['Run is created', 'RunStarted event is emitted'],
},
{
key: 'execute-agent-not-active',
given: ['Agent exists but is not active'],
when: ['User attempts to execute'],
then: ['AGENT_NOT_ACTIVE error is returned'],
},
],
examples: [
{
key: 'basic-execute',
input: { agentId: 'agent-123', input: { message: 'Hello' } },
output: { runId: 'run-456', status: 'pending', estimatedWaitMs: 5000 },
},
],
},
});