Skip to content

Add AI agent conversations landed by the AI Sessionizer - #14057

Open
wu-sheng wants to merge 1 commit into
masterfrom
feat/ai-agent-conversation
Open

Add AI agent conversations landed by the AI Sessionizer#14057
wu-sheng wants to merge 1 commit into
masterfrom
feat/ai-agent-conversation

Conversation

@wu-sheng

@wu-sheng wu-sheng commented Sep 5, 2026

Copy link
Copy Markdown
Member

Add AI agent conversations landed by the AI Sessionizer


The AI Sessionizer collects an agent runtime's transcripts into two file formats, Session Data (.sd) and Session Flow (.sf, an append-only chain of rounds), and pushes every file as one OTLP log record. This PR makes the OAP store them and serve a conversation whole.

Ingest. A new AI_AGENT layer routes the records to the bundled LAL rule lal/ai-agent.yaml. Its output builder, ConversationFile, verifies each file's sha256 and line count against the record attributes and stores it verbatim, or drops it and counts the reason in ai_agent_conversation_files_rejected. Nothing is decoded at ingest, so a cluster needs no shared state.

Storage. Two record models, ai_agent_session_data and ai_agent_session_flow, super datasets on every storage, in a BanyanDB group of their own, recordsAIAgent, with hot, warm and cold stages like the log group. A row belongs to its sender: its id is the service, the instance and the file digest, so a retry lands on the same row and another sender's copy is another row.

Query. The list page and the raw-file export are GraphQL queries, listConversations and getConversationRawFiles. The conversation itself is GET /ai-agent/conversations/{conversation}/v1/view on the core HTTP server beside /graphql: one asz.view 1.0 document, equal key for key to the one asz conversation prints for the same files, streamed as it is rendered, Content-Type: application/vnd.skywalking.asz.view+json; version=1.0 or the +yaml twin, gzip on Accept-Encoding, errors as application/problem+json, under its own timeout. It is not a GraphQL query because a long conversation renders to tens of megabytes: measured, a 136 MB session folds to a 70 MB document in about eleven seconds, past the HTTP server's ten second default. Rounds and files are read window by window (roundReadWindow, fileReadWindow), across every sender when none is named, and over every retained stage on BanyanDB.

Tests. Unit tests compare the built document with the Sessionizer's own output for the same files, cover the file builder, the formats, the raw-JSON preservation, and the route on an in-process server (JSON, YAML, gzip, chunking, UTF-8 at a chunk boundary, the error statuses). The e2e, one shared case on BanyanDB, Elasticsearch, MySQL and PostgreSQL, builds sessions with the Sessionizer's scenario tool, lands one in three stages, pushes everything to the OAP, and reads it back through swctl ai-agent list, files and view (apache/skywalking-cli#234, pinned as SW_CTL_COMMIT), comparing every document with the one the Sessionizer's viewer serves, over HTTP/1.1 and HTTP/2, as JSON and YAML, gzipped or not, plus the export's digests, a rejected file, and the three-round chain. All four passed locally.

Unrelated e2e fix. The Agent PHP e2e image (test/e2e-v2/cases/php/Dockerfile.php) moves from php:8.1-fpm-bullseye to php:8.1-fpm-bookworm: the bullseye apt mirror answers 404 for nginx on the CI runners, so the case failed on every run. The rustup download now follows the build host's architecture, so the image also builds on arm64 machines. The PHP extension directory is unchanged (PHP 8.1). Verified locally: the image builds natively and under --platform linux/amd64, and the PHP e2e passes 30/30.

Known limit. On JDBC, a retry of the same file by the same sender hits the same primary key, which the shared record writer's plain INSERT rejects; BanyanDB and Elasticsearch treat it as a duplicate the reader ignores or an overwrite. Content under a key is immutable by construction, so an insert-or-ignore in the common JDBC writer would be safe; that is a change outside this feature.

@wu-sheng wu-sheng added this to the 11.1.0 milestone Sep 5, 2026
@wu-sheng wu-sheng added backend OAP backend related. query OAP query protocol related logging Log collecting and analysis labels Sep 5, 2026
@wu-sheng
wu-sheng requested review from peachisai and wankai123 and removed request for wankai123 September 5, 2026 04:51
@wu-sheng
wu-sheng force-pushed the feat/ai-agent-conversation branch 5 times, most recently from 9b6dbd9 to c0bfe3e Compare September 5, 2026 10:58
The AI Sessionizer (apache/skywalking-ai-sessionizer) pushes an agent
runtime's conversation as Session Data and Session Flow files over OTLP
logs under a new AI_AGENT layer. The OAP verifies each file's digest and
line count in the bundled LAL rule's ConversationFile output builder,
stores it verbatim in two record models, ai_agent_session_data and
ai_agent_session_flow, in a BanyanDB group of their own, recordsAIAgent,
and answers a conversation with one asz.view 1.0 document, equal key for
key to the one the Sessionizer prints for the same files.

The list page and the raw-file export are GraphQL queries,
listConversations and getConversationRawFiles. The document itself is
served by GET /ai-agent/conversations/{conversation}/v1/view on the same
HTTP server, streamed and compressed under its own timeout, because a
long conversation renders to tens of megabytes: measured, a 136 MB
session folds to a 70 MB document in about eleven seconds, past the
server's ten second default. Its Content-Type names the format and the
version, application/vnd.asz.view+json; version=1.0 or the +yaml twin,
and an error is an application/problem+json document.

The e2e builds sessions with the Sessionizer's own scenario tool, lands
one of them in three stages, pushes everything to the OAP, and compares
every document with the one the Sessionizer's viewer serves, over
HTTP/1.1 and HTTP/2, as JSON and YAML, gzipped or not.
@wu-sheng
wu-sheng force-pushed the feat/ai-agent-conversation branch from c0bfe3e to 0beff52 Compare September 5, 2026 13:45
@wu-sheng
wu-sheng requested a review from wankai123 September 5, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend OAP backend related. logging Log collecting and analysis query OAP query protocol related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants