feat(agents): Logging support for agent sessions#28491
feat(agents): Logging support for agent sessions#28491mike12345567 wants to merge 22 commits inton8n-agentsfrom
Conversation
…an emoji for the thread/memory storage.
Bundle ReportChanges will increase total bundle size by 82.75kB (0.18%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: editor-ui-esmAssets Changed:
Files in
Files in
Files in
|
Merging this PR will improve performance by 17.8%
Performance Changes
Comparing Footnotes
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Performance ComparisonComparing current → latest master → 14-day baseline Idle baseline with Instance AI module loaded
Memory consumption baseline with starter plan resources
docker-stats
How to read this table
|
There was a problem hiding this comment.
12 issues found across 38 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/cli/src/modules/agents/agent-execution.service.ts">
<violation number="1" location="packages/cli/src/modules/agents/agent-execution.service.ts:105">
P2: Regex doesn't strip the angle brackets from Slack-style mentions (`<@U0ANB4K6611>`). The pattern matches `@U0ANB4K6611` inside the brackets but leaves `<` and `>` in the output, producing `<@AgentName>` instead of `@AgentName`. Extend the pattern to match the full `<@…>` wrapper as well.</violation>
<violation number="2" location="packages/cli/src/modules/agents/agent-execution.service.ts:239">
P0: Custom agent: **Security Review**
Authorization bypass: executions are deleted before verifying thread ownership. An authenticated user who knows a `threadId` from another project can destroy its executions by calling `DELETE /projects/{own-project}/agents/v2/threads/{victim-thread-id}`. The ownership check via `deleteByIdAndProjectId` only runs after the unconditional `executionRepository.delete({ threadId })`. Verify ownership first, then delete executions.</violation>
</file>
<file name="packages/frontend/editor-ui/src/features/agents/components/AgentHomeContent.vue">
<violation number="1" location="packages/frontend/editor-ui/src/features/agents/components/AgentHomeContent.vue:32">
P2: New user-facing strings are hard-coded in English instead of going through i18n, so this UI will not localize correctly.</violation>
<violation number="2" location="packages/frontend/editor-ui/src/features/agents/components/AgentHomeContent.vue:174">
P2: The session row is click-only on a `<div>`, which makes session selection inaccessible to keyboard users.</violation>
</file>
<file name="packages/frontend/editor-ui/src/features/execution/executions/views/ExecutionsView.vue">
<violation number="1" location="packages/frontend/editor-ui/src/features/execution/executions/views/ExecutionsView.vue:53">
P2: Using raw `route.query.view` to skip initialization breaks workflow execution loading when `view=agents` is present but Agents is disabled.</violation>
<violation number="2" location="packages/frontend/editor-ui/src/features/execution/executions/views/ExecutionsView.vue:74">
P2: Visibility-change auto-refresh restart uses query-only mode detection, so workflow auto-refresh can remain stopped when `view=agents` is set but Agents is unavailable.</violation>
</file>
<file name="packages/frontend/editor-ui/src/features/agents/components/RichInteractionCard.vue">
<violation number="1" location="packages/frontend/editor-ui/src/features/agents/components/RichInteractionCard.vue:187">
P3: Replace hard-coded dimensions with design system sizing tokens.</violation>
</file>
<file name="packages/cli/src/modules/agents/agents.service.ts">
<violation number="1" location="packages/cli/src/modules/agents/agents.service.ts:346">
P1: Do not skip recording when `recorder.suspended` is true. Set `hitlStatus` to `'suspended'` if the agent suspends again, so intermediate tool calls are not lost.</violation>
</file>
<file name="packages/frontend/editor-ui/src/features/agents/views/AgentSessionsListView.vue">
<violation number="1" location="packages/frontend/editor-ui/src/features/agents/views/AgentSessionsListView.vue:127">
P2: The session status cell is hardcoded to “success”, so non-success threads will be displayed with incorrect status.</violation>
</file>
<file name="packages/cli/src/modules/agents/agents.controller.ts">
<violation number="1" location="packages/cli/src/modules/agents/agents.controller.ts:147">
P2: `limit` parsing allows negative values; enforce a minimum bound before passing to thread queries.</violation>
</file>
<file name="packages/frontend/editor-ui/src/features/agents/agentSessions.store.ts">
<violation number="1" location="packages/frontend/editor-ui/src/features/agents/agentSessions.store.ts:83">
P2: Handle refresh errors inside the auto-refresh timer callback; otherwise a single failed fetch stops all subsequent auto-refresh cycles.</violation>
</file>
<file name="packages/cli/src/modules/agents/execution-recorder.ts">
<violation number="1" location="packages/cli/src/modules/agents/execution-recorder.ts:184">
P2: New tool-call events are marked successful before completion, so suspended or missing-result calls can be incorrectly reported as success.</violation>
</file>
Architecture diagram
sequenceDiagram
participant UI as Frontend (Sessions/Executions)
participant API as Agents Controller
participant AS as Agent Service
participant AES as Agent Execution Service
participant ER as Execution Recorder
participant AR as Agent Runtime
participant DB as Database (Postgres/SQLite)
Note over UI, DB: Agent Message Execution & Logging Flow
UI->>API: POST /agents/:id/chat (message)
API->>AS: executeForChat()
AS->>AR: stream()
loop Stream Processing
AR->>AS: StreamChunk (text, tool-call, etc)
AS->>UI: Relay Chunk
AS->>ER: NEW: record(chunk)
opt NEW: Working Memory Update
AR->>AR: WorkingMemoryStreamFilter
AR->>ER: chunk (type: 'working-memory-update')
end
end
opt CHANGED: Title Generation (First message)
AR->>AR: generateThreadTitle()
Note right of AR: NEW: Request JSON with title + emoji
AR->>DB: Save thread title & metadata
end
AR-->>AS: Stream Finished
AS->>ER: NEW: getMessageRecord()
ER-->>AS: { tokens, cost, toolCalls, timeline, etc }
AS->>AES: NEW: recordMessage()
AES->>DB: CHANGED: findOrCreate ExecutionThread
Note right of DB: Tracks session aggregates (cost, tokens)
alt Cycle Suspended (HITL)
AES->>DB: NEW: Insert Execution (status: 'success', hitlStatus: 'suspended')
else Cycle Completed
AES->>DB: NEW: Insert Execution (mode: 'agent', threadId: xxx)
AES->>DB: NEW: Insert Metadata (tokens, model, tool outputs, timeline)
AES->>DB: NEW: Update Thread (increment total tokens/cost)
opt Was Resumed
AES->>DB: NEW: backfillSuspendedExecutions()
Note right of DB: Propagates model/usage to previous suspended records
end
end
Note over UI, DB: Session Retrieval Flow
UI->>API: GET /threads?agentId=...
API->>AES: getThreads()
AES->>DB: Query execution_threads
DB-->>AES: Thread list + aggregates
AES->>DB: Query execution_metadata (latest userMessage)
AES-->>API: Paginated threads
API-->>UI: 200 OK (Displays in Global Executions or Agent Sessions)
UI->>API: GET /threads/:threadId
API->>AES: getThreadDetail()
AES->>DB: Query execution_entity + metadata where threadId
DB-->>AES: Chronological execution list
AES-->>API: Thread + Timeline data
API-->>UI: 200 OK (Renders RichInteractionCards & Timeline)
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
packages/frontend/editor-ui/src/features/agents/components/AgentHomeContent.vue
Show resolved
Hide resolved
packages/frontend/editor-ui/src/features/agents/components/AgentHomeContent.vue
Show resolved
Hide resolved
packages/frontend/editor-ui/src/features/agents/views/AgentSessionsListView.vue
Outdated
Show resolved
Hide resolved
packages/frontend/editor-ui/src/features/agents/agentSessions.store.ts
Outdated
Show resolved
Hide resolved
packages/frontend/editor-ui/src/features/agents/components/RichInteractionCard.vue
Outdated
Show resolved
Hide resolved
…olumn - Watch route query to initialize executions store when switching from agents view back to workflows (was skipped on mount) - Always record resumed HITL executions even if they suspend again, so chained approval/form flows appear in the session timeline - Remove hardcoded success status column from session list tables since per-thread status is not tracked Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Verify thread ownership before deleting executions (prevents cross-project data destruction via known threadId) - Fix Slack mention regex to handle <@U0ANB4K6611> angle bracket format - Clamp thread list limit to 1-100 (prevent negative values) - Default tool-call timeline events to success=false until result confirms completion - Catch errors in auto-refresh timer so cycle continues on failure - Gate agents view checks on module availability, not just query param - Use design system tokens for RichInteractionCard dimensions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
execution_threadstable + migration to group executions by conversation thread, tracking session-level aggregates (total tokens, cost, duration)ExecutionRecorderextracts structured data from agent stream chunks;AgentExecutionServicepersists execution records and manages thread lifecycleRichInteractionCardcomponent rendersrich_interactiontool calls inline in session detailScreenshots
Recent conversations (sessions):

Table listing sessions in the executions section (see switcher on the right):

Detailed timeline of the session (tool calls, HITL, etc):

Review / Merge checklist
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)