---
title: "生成会话标题"
method: POST
path: "/sessions/{session_id}/title"
tags: ["会话"]
---

# 生成会话标题

`POST /sessions/{session_id}/title`

根据消息内容自动生成会话标题

## Path parameters

- `session_id` string, required

## Request body

- InternalHandlerSessionGenerateTitleRequest
  - `messages` GithubComTencentWeKnoraInternalTypesMessage[], required — Messages to use as context for title generation
    - `agent_duration_ms` integer — Agent total execution duration in milliseconds (from query start to answer start)
    - `agent_id` string — AgentID is the agent used for this individual assistant turn. Unlike the session's last_request_state it remains stable when users switch agents.
    - `agent_steps` GithubComTencentWeKnoraInternalTypesAgentStep[] — Agent execution steps (only for assistant messages generated by agent) This contains the detailed reasoning process and tool calls made by the agent Stored for user history display, but NOT included in LLM context to avoid redundancy
      - `iteration` integer — Iteration number (0-indexed)
      - `reasoning_content` string — ReasoningContent stores the OpenAI-protocol reasoning_content emitted by the model in this round. Persisted on AgentStep so cross-turn replay can put it back on the assistant message — required by MiMo / DeepSeek V3.2+ thinking mode, ignored by providers that don't recognize the field.
      - `thought` string — LLM's reasoning/thinking (Think phase)
      - `timestamp` string — When this step occurred
      - `tool_calls` GithubComTencentWeKnoraInternalTypesToolCall[] — Tools called in this step (Act phase)
        - `args` object — Tool arguments
        - `duration` integer — Execution time in milliseconds
        - `id` string — Function call ID from LLM
        - `name` string — Tool name
        - `provider_metadata` GithubComTencentWeKnoraInternalTypesToolCallMetadata
        - `reflection` string — Agent's reflection on this tool call result (if enabled)
        - `result` GithubComTencentWeKnoraInternalTypesToolResult
          - `data` object — Structured data for programmatic use
          - `error` string — Error message if execution failed
          - `images` string[] — Base64 data URIs from tool (e.g. MCP image content)
          - `output` string — Human-readable output
          - `success` boolean — Whether the tool executed successfully
    - `attachments` GithubComTencentWeKnoraInternalTypesMessageAttachment[] — Attached files (documents, audio, etc., for user messages)
      - `content` string — Extracted text content (for small text files)
      - `content_mode` string — full or selected_chunks
      - `file_name` string — Original filename
      - `file_size` integer — File size in bytes
      - `file_type` string — File extension (e.g., ".pdf", ".docx")
      - `id` string — Temporary document ID for session-scoped uploads
      - `is_truncated` boolean — Whether content was truncated
      - `line_count` integer — Total line count (for text files)
      - `selected_chunks` integer — Chunks included in this message prompt
      - `token_count` integer — Approximate tokens in the parsed document
      - `total_chunks` integer — Total parsed chunks
    - `channel` string — Channel indicates the source channel of this message (e.g., "web", "api", "im")
    - `content` string — Message text content
    - `created_at` string — Message creation timestamp
    - `deleted_at` GormDeletedAt
      - `time` string
      - `valid` boolean — Valid is true if Time is not NULL
    - `id` string — Unique identifier for the message
    - `images` GithubComTencentWeKnoraInternalTypesMessageImage[] — Attached images with OCR/Caption text (for user messages)
      - `caption` string
      - `url` string
    - `is_completed` boolean — Whether message generation is complete
    - `is_fallback` boolean — Whether this response is a fallback (no knowledge base match found)
    - `knowledge_id` string — KnowledgeID links this message to a Knowledge entry in the chat history knowledge base Used for vector search indexing: when set, the message content has been indexed as a Knowledge passage
    - `knowledge_references` GithubComTencentWeKnoraInternalTypesSearchResult[] — References to knowledge chunks used in the response
      - `chunk_index` integer — Chunk index
      - `chunk_metadata` integer[] — ChunkMetadata stores chunk-level metadata (e.g., generated questions)
      - `chunk_type` string — Chunk 类型
      - `content` string — Content
      - `end_at` integer — End at
      - `id` string — ID
      - `image_info` string — 图片信息 (JSON 格式)
      - `knowledge_base_id` string — KnowledgeBaseID is the ID of the knowledge base this result belongs to
      - `knowledge_channel` string — KnowledgeChannel indicates through which channel the knowledge was ingested (web, api, wechat, etc.)
      - `knowledge_custom_metadata` string — KnowledgeCustomMetadata is user-authored context safe to expose to models.
      - `knowledge_description` string — KnowledgeDescription is the description of the knowledge document
      - `knowledge_filename` string — Knowledge file name Used for file type knowledge, contains the original file name
      - `knowledge_id` string — Knowledge ID
      - `knowledge_source` string — Knowledge source Used to indicate the source of the knowledge, such as "url"
      - `knowledge_title` string — Knowledge title
      - `match_type` 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
      - `matched_content` string — MatchedContent is the actual content that was matched in vector search For FAQ: this is the matched question text (standard or similar question)
      - `metadata` object — Metadata
      - `parent_chunk_id` string — 父 Chunk ID
      - `score` number — Score
      - `seq` integer — Seq
      - `start_at` integer — Start at
      - `sub_chunk_id` string[] — SubChunkIndex
    - `mentioned_items` GithubComTencentWeKnoraInternalTypesMentionedItem[] — Mentioned knowledge bases and files (for user messages) Stores the @mentioned items when user sends a message
      - `id` string
      - `kb_id` string — Parent knowledge base for file/tag mentions
      - `kb_name` string — Display name for parent KB
      - `kb_type` string — "document" or "faq" (only for kb type)
      - `name` string
      - `service_id` string — Parent MCP service for MCP tool mentions
      - `skill_name` string — Preloaded agent skill name
      - `type` string — "kb", "file", "tag", "mcp", "skill"
    - `model_id` string — ModelID is the requested/effective chat model binding captured for this turn. It is useful for reproducibility and suggestion generation.
    - `request_id` string — Request identifier for tracking API requests
    - `role` string — Message role: "user", "assistant", "system"
    - `session_id` string — ID of the session this message belongs to
    - `updated_at` string — Last update timestamp

## Response `200`

生成的标题

- object

## Other responses

- `400` — 请求参数错误

---

[API](https://skmtc.net/tencentblueking/apis/weknora-api.md) · [All operations](https://skmtc.net/tencentblueking/apis/weknora-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/tencentblueking/weknora-api/versions/d6921ae22ce0/schema)
