Auto-Pilot
Updated a month ago

runtime

Aassistant-ui
0.0k
assistant-ui/skills/assistant-ui/skills/runtime
72
Agent Score

💡 Summary

English summary.

🎯 Target Audience

Persona 1Persona 2Persona 3

🤖 AI Roast:Powerful, but the setup might scare off the impatient.

Security AnalysisLow Risk

Risk: Low. Review: outbound network access (SSRF, data egress). Run with least privilege and audit before enabling in production.


name: runtime description: Guide for assistant-ui runtime system and state management. Use when working with runtimes, accessing state, or managing thread/message data. version: 0.0.1 license: MIT

assistant-ui Runtime

Always consult assistant-ui.com/llms.txt for latest API.

References

Runtime Hierarchy

AssistantRuntime
├── ThreadListRuntime (thread management)
│   ├── ThreadListItemRuntime (per-thread item)
│   └── ...
└── ThreadRuntime (current thread)
    ├── ComposerRuntime (input state)
    └── MessageRuntime[] (per-message)
        └── MessagePartRuntime[] (per-content-part)

State Access (Modern API)

import { useAssistantApi, useAssistantState, useAssistantEvent } from "@assistant-ui/react"; function ChatControls() { const api = useAssistantApi(); const messages = useAssistantState(s => s.thread.messages); const isRunning = useAssistantState(s => s.thread.isRunning); useAssistantEvent("message-added", (e) => { console.log("New message:", e.message); }); return ( <div> <button onClick={() => api.thread().append({ role: "user", content: [{ type: "text", text: "Hello!" }], })}> Send </button> {isRunning && ( <button onClick={() => api.thread().cancelRun()}>Cancel</button> )} </div> ); }

Thread Operations

const api = useAssistantApi(); const thread = api.thread(); // Append message thread.append({ role: "user", content: [{ type: "text", text: "Hello" }] }); // Cancel generation thread.cancelRun(); // Get current state const state = thread.getState(); // { messages, isRunning, ... }

Message Operations

const message = api.thread().message(0); // By index message.edit({ role: "user", content: [{ type: "text", text: "Updated" }] }); message.reload();

Events

useAssistantEvent("thread-started", () => {}); useAssistantEvent("thread-ended", () => {}); useAssistantEvent("message-added", ({ message }) => {}); useAssistantEvent("run-started", () => {}); useAssistantEvent("run-ended", () => {});

Capabilities

const caps = useAssistantState(s => s.thread.capabilities); // { cancel, edit, reload, copy, speak, attachments }

Quick Reference

// Get messages const messages = useAssistantState(s => s.thread.messages); // Check running state const isRunning = useAssistantState(s => s.thread.isRunning); // Append message api.thread().append({ role: "user", content: [{ type: "text", text: "Hi" }] }); // Cancel generation api.thread().cancelRun(); // Edit message api.thread().message(index).edit({ ... }); // Reload message api.thread().message(index).reload();

Common Gotchas

"Cannot read property of undefined"

  • Ensure hooks are called inside AssistantRuntimeProvider

State not updating

  • Use selectors with useAssistantState to prevent unnecessary re-renders

Messages array empty

  • Check runtime is configured
  • Verify API response format
5-Dim Analysis
Clarity8/10
Novelty6/10
Utility8/10
Completeness7/10
Maintainability7/10
Pros & Cons

Pros

  • p1
  • p2

Cons

  • c1
  • c2

Related Skills

claude-domain-skills

B
toolAuto-Pilot
72/ 100

“Powerful, but the setup might scare off the impatient.”

my-skills

B
toolAuto-Pilot
72/ 100

“Powerful, but the setup might scare off the impatient.”

terraform-ibm-modules-skills

B
toolAuto-Pilot
72/ 100

“Powerful, but the setup might scare off the impatient.”

Disclaimer: This content is sourced from GitHub open source projects for display and rating purposes only.

Copyright belongs to the original author assistant-ui.