-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Agents streaming #1315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Agents streaming #1315
Conversation
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 276cafb The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 2 comments
Greptile OverviewGreptile SummaryThis PR refactors the agent streaming API by moving the Key Changes:
Issues Found: Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant V3
participant AgentHandler
participant AgentCache
participant LLMClient
User->>V3: agent({ stream: true })
V3->>V3: Validate config (no CUA + stream)
V3-->>User: Return agent instance
User->>V3: agent.execute(instruction)
V3->>V3: prepareAgentExecution()
V3->>AgentCache: tryReplayAsStream()
alt Cache Hit
AgentCache->>AgentCache: createCachedStreamResult()
AgentCache-->>V3: Mock AgentStreamResult
V3-->>User: Cached stream result
else Cache Miss
V3->>AgentHandler: stream(instruction)
AgentHandler->>AgentHandler: prepareAgent()
AgentHandler->>LLMClient: streamText()
loop Streaming chunks
LLMClient-->>User: textStream chunks
LLMClient->>AgentHandler: onStepFinish()
AgentHandler->>AgentHandler: Update state
end
LLMClient->>AgentHandler: onFinish()
AgentHandler->>AgentHandler: consolidateMetricsAndResult()
AgentHandler-->>V3: AgentStreamResult
V3->>AgentCache: wrapStreamForCaching()
AgentCache->>AgentCache: beginRecording()
AgentCache->>AgentCache: Store on completion
V3-->>User: AgentStreamResult
User->>User: Iterate textStream
User->>User: await result
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 files reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 8 files
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/core/lib/v3/handlers/v3AgentHandler.ts">
<violation number="1" location="packages/core/lib/v3/handlers/v3AgentHandler.ts:158">
Errors from prepareAgent are now thrown outside the try/catch, so execute() can reject instead of returning a failure AgentResult.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
why
Simplify the agent streaming API by moving the
streamflag into agent configuration. This allows TypeScript to properly infer return types at compile time and provides a cleaner API with a singleexecute()method.what changed
stream?: booleantoAgentConfigagent({ stream: true }).execute()→ returnsAgentStreamResultagent().execute()→ returnsAgentResult(unchanged)V3AgentHandlerand caching layerprepareAgentExecution()helpertest plan