Interface Agent

A stateful agent instance returned by agent.

interface Agent {
    generate(prompt, opts?): Promise<GenerateTextResult>;
    stream(prompt, opts?): StreamTextResult;
    session(id?, options?): AgentSession;
    usage(sessionId?): Promise<AgentOSUsageAggregate>;
    close(): Promise<void>;
    learning?: AgentLearning;
    export(metadata?, options?): AgentExportConfig;
    exportJSON(metadata?, options?): string;
    getAvatarBindings(): AvatarBindingInputs & Record<string, unknown>;
    setAvatarBindingOverrides(overrides): void;
    voiceSession?(request): Promise<ManagedVoiceSession>;
}

Methods

  • Generates a single reply without maintaining session history. Accepts plain text or multimodal content (text + image parts).

    Parameters

    • prompt: MessageContent

      User prompt as text string or MessageContent array.

    • Optional opts: Partial<GenerateTextOptions>

      Optional overrides merged on top of the agent's base options.

    Returns Promise<GenerateTextResult>

    The complete generation result.

  • Releases all in-memory session state held by this agent.

    Returns Promise<void>

  • Exports the agent's configuration as a portable object. Secrets are redacted unless options.redactSecrets is false.

    Parameters

    • Optional metadata: {
          name?: string;
          description?: string;
          author?: string;
          tags?: string[];
      }

      Optional human-readable metadata to attach.

      • Optional name?: string
      • Optional description?: string
      • Optional author?: string
      • Optional tags?: string[]
    • Optional options: ExportAgentConfigOptions

      Redaction options.

    Returns AgentExportConfig

    A portable AgentExportConfig object.

  • Exports the agent's configuration as a pretty-printed JSON string. Secrets are redacted unless options.redactSecrets is false.

    Parameters

    • Optional metadata: {
          name?: string;
          description?: string;
          author?: string;
          tags?: string[];
      }

      Optional human-readable metadata to attach.

      • Optional name?: string
      • Optional description?: string
      • Optional author?: string
      • Optional tags?: string[]
    • Optional options: ExportAgentConfigOptions

      Redaction options.

    Returns string

    JSON string.

  • Read current avatar binding state (auto-populated from mood/voice/relationship).

    Returns AvatarBindingInputs & Record<string, unknown>

  • Inject game-specific binding overrides (healthBand, combatMode, etc.).

    Parameters

    • overrides: Record<string, unknown>

    Returns void

  • Prepares the configured scoped voice call; present only with voice.session.

    Parameters

    • request: Omit<StartVoiceSession, "agent">

    Returns Promise<ManagedVoiceSession>

Properties

learning?: AgentLearning

The agent's learning layer as its host reads it. Set only with runtime: 'gmi' and learning on.