Skip to content

feat: Pi agent message stdout streaming - #4071

Open
maciaszczykm wants to merge 1 commit into
masterfrom
marcin/prod-5116-agent-message-stdo-streaming
Open

feat: Pi agent message stdout streaming#4071
maciaszczykm wants to merge 1 commit into
masterfrom
marcin/prod-5116-agent-message-stdo-streaming

Conversation

@maciaszczykm

@maciaszczykm maciaszczykm commented Aug 28, 2026

Copy link
Copy Markdown
Member

Test Plan

Test environment: https://console.plrl-dev-aws.onplural.sh/

Checklist

  • I have added a meaningful title and summary to convey the impact of this PR to a user.
  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have deployed the agent to a test environment and verified that it works as expected (required only when changing agent code).

Plural Flow: console

@linear

linear Bot commented Aug 28, 2026

Copy link
Copy Markdown

PROD-5116

@soffi-ai

soffi-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Soffi AI Summary

This PR introduces real-time stdout streaming for AI agent messages during agent runs. Previously, tool call output was only available after completion; now, as an agent harness executes tool calls, intermediate stdout is streamed incrementally to the Console server via a new AgentMessageOutput GraphQL mutation and surfaced live in the UI.

The core change is a new Streamer component in the deployment operator (go/deployment-operator/pkg/agentrun-harness/output/streamer.go) that buffers per-message stdout, flushes on a size limit or time interval, and drains all in-flight messages on context cancellation or explicit close — with deliberate no-retry semantics on failed flushes to avoid duplicating already-delivered deltas. The agent message controller and tool interfaces are wired up to feed output into the streamer. On the frontend, the AI agent run detail view and tool call content components are updated to render streaming stdout inline as messages arrive.

Changes

Agent message stdout streaming

  • Adds a buffered stdout streamer (output.Streamer) in the deployment operator that incrementally flushes agent tool-call output to the Console server via a new AgentMessageOutput GraphQL mutation. Flushes are triggered by a configurable size limit or time interval, and all pending streams are drained concurrently on context cancellation or CloseAll. The Go client, agent message controller, and tool interfaces are wired to feed data into the streamer. The React frontend is updated to render streaming stdout in the agent run detail view and tool call content components. A comprehensive test suite covers size-limit flushing, delta-only writes, interval flushing, no-retry on failure, concurrent CloseAll, and race conditions between Close and context cancellation. (4fcb115)

Updated: 2026-08-28 13:59 UTC

Deploy in Soffi

@maciaszczykm maciaszczykm added the enhancement New feature or request label Aug 28, 2026
@maciaszczykm

Copy link
Copy Markdown
Member Author

@greptileai

@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR streams live agent tool stdout from the deployment-operator harness through Console GraphQL subscriptions into the agent-run UI.

  • Adds per-tool-call buffering, delta extraction, bounded frontend display state, and close-time flushing.
  • Connects tool output callbacks to the new Console mutation and subscription contracts.
  • Updates agent-run tool rendering to show stdout while execution is pending.

Confidence Score: 4/5

The PR is not yet safe to merge because transient Console delivery failures still permanently drop both intermediate and final stdout chunks.

The streamer clears buffered output before delivery and deliberately performs no retry, so temporary API failures leave permanent gaps; the same behavior during the sole close-time flush loses the final chunk after its stream has been retired.

Files Needing Attention: go/deployment-operator/pkg/agentrun-harness/output/streamer.go

Important Files Changed

Filename Overview
go/deployment-operator/pkg/agentrun-harness/output/streamer.go Implements bounded per-call delta buffering and concurrent shutdown flushing, while the previously reported regular and final delivery-loss behavior remains.
go/deployment-operator/pkg/agentrun-harness/controller/agent_messages.go Connects tool-message identities and accumulated output callbacks to the streamer lifecycle.
go/deployment-operator/pkg/agentrun-harness/tool/pi/pi.go Emits accumulated partial tool results through the harness output callback.
go/deployment-operator/pkg/client/agentrun.go Adds the client wrapper that publishes stdout and stderr through the agent-message-output mutation.
assets/src/components/ai/agent-runs/details/AIAgentRunMessages.tsx Subscribes to stdout deltas, keeps bounded per-message display state, and overlays streamed output while tools are pending.
assets/src/components/ai/chatbot/ToolCallContent.tsx Renders live response content instead of the running placeholder once pending output is available.
assets/src/graph/ai/agent.graphql Adds the run-scoped agent-message-output subscription consumed by the agent-run UI.

Reviews (11): Last reviewed commit: "add agent message stdout streaming" | Re-trigger Greptile

Comment thread go/deployment-operator/pkg/agentrun-harness/output/streamer.go
Comment thread go/deployment-operator/pkg/agentrun-harness/output/streamer.go
Comment thread go/deployment-operator/pkg/agentrun-harness/output/streamer.go
@maciaszczykm
maciaszczykm marked this pull request as ready for review August 28, 2026 11:02
Comment thread go/deployment-operator/pkg/agentrun-harness/output/streamer.go Outdated
Comment on lines +251 to +254
if err != nil {
klog.ErrorS(err, "failed to flush agent message output", "messageID", st.messageID, "bytes", n)
return
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Retries duplicate accepted output

When Console accepts an AgentMessageOutput request but the client receives a timeout or connection reset, this error path retains and later resends the same stdout delta. The frontend appends both deliveries, causing duplicated tool output.

Comment thread go/deployment-operator/pkg/agentrun-harness/output/streamer.go Outdated
Comment thread go/deployment-operator/pkg/agentrun-harness/output/streamer.go Outdated
Comment thread go/deployment-operator/pkg/agentrun-harness/output/streamer.go Outdated
Comment thread go/deployment-operator/pkg/agentrun-harness/output/streamer.go Outdated
@maciaszczykm
maciaszczykm force-pushed the marcin/prod-5116-agent-message-stdo-streaming branch from 8d637fe to c1ff067 Compare August 28, 2026 13:14
Comment thread go/deployment-operator/pkg/agentrun-harness/output/streamer.go Outdated
@maciaszczykm
maciaszczykm force-pushed the marcin/prod-5116-agent-message-stdo-streaming branch 2 times, most recently from b5151cf to 978e31b Compare August 28, 2026 13:52
@maciaszczykm

Copy link
Copy Markdown
Member Author

@greptileai

@maciaszczykm
maciaszczykm force-pushed the marcin/prod-5116-agent-message-stdo-streaming branch from 978e31b to 4fcb115 Compare August 28, 2026 13:59
@maciaszczykm maciaszczykm changed the title feat: Agent message stdout streaming feat: Pi agent message stdout streaming Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant