ViteHub is still experimental. Expect bugs and breaking changes.

Chat summary

Add a summary command that replaces explicit input with a conversation summary.

chatSummary() adds a conversation summary command. It looks for an explicit command in the latest user input, generates a summary, replaces the command with summary text, and exposes the generated summary as output metadata.

The Capability contributes input behavior similar to inputCommands(). By default it recognizes a summary command, summarizes the current conversation, and writes the summary into Agent Run Input context.

Configure summaries

Attach chatSummary() with chat() to let users request a summary from a chat interface. The default command uses the standard input command trigger.

server/agents/support.ts
import { defineAgent } from 'vite-hub/agent'
import { chat, chatSummary } from 'vite-hub/agent/capabilities'

export default defineAgent({
  driver: { model },
  capabilities: [
    chat(),
    chatSummary(),
  ],
})

How summaries work

chatSummary() runs during the input phase. When the configured command is present, it removes the command text, summarizes the source messages with a model, custom executor, or heuristic fallback, then replaces the command with Conversation summary.

The generated value is available as chatSummary in input context and as a finish extension for the invocation that generated it.

Requirements

The command name must be a valid Input Command name. Model-based summaries require an explicit model option; otherwise the Capability uses its heuristic fallback.

Disable the command only when application code invokes the summary behavior directly.

Driver support

Agent DriverSupport
Model-backedReceives the transformed input containing the generated summary.
Provider-backedReceives the transformed input before provider execution.
Custom-run-backedReceives the transformed input and context values before driver.run.

Verify summaries

Run a chat invocation with the summary command. Inspect the final Agent Run Input and confirm the command was replaced with Conversation summary text.

Inspect the finish extension and verify it appears only on the invocation that generated the summary.

Options

OptionTypeDefaultDescription
commandfalse | ChatSummaryCommandOptions{ name: "summary", trigger: "/" }Enables or configures the summary Input Command.
command.namestring"summary"Command name.
command.triggerstring"/"Command prefix.
command.descriptionstringgeneratedCommand description.
execute(input) => string | { summary?: string }noneCustom summary generator.
fallbackstring"No conversation to summarize."Summary used when generation returns no usable text.
idstring"chat-summary"Capability id and summary context key prefix.
instructionsstringgeneratedSystem instructions for model-backed summaries.
maxLengthnumber1200Maximum summary length.
modelAI SDK modelheuristic fallbackModel used for summaries.