Repository navigation
Graphai llm stream data tools progress - #1208
Conversation
|
Warning Rate limit exceeded@isamu has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 51 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (8)
WalkthroughAdds a new GraphAILLMStreamDataToolsProgress type representing in-progress tool-call events in streaming LLM responses and includes it in the GraphAILLMStreamData union. Also bumps llm_agents/llm_utils package version from 2.0.1 to 2.0.3. No other fields or logic changed. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant LLM_Stream
participant Dispatcher
participant Consumer
Client->>LLM_Stream: Start streaming
LLM_Stream-->>Dispatcher: response.create
Dispatcher-->>Consumer: Create event
LLM_Stream-->>Dispatcher: response.in_progress (text)
Dispatcher-->>Consumer: Progress (text)
LLM_Stream-->>Dispatcher: response.in_progress (tool_calls)
Dispatcher-->>Consumer: ToolsProgress (output[*] -> {id?, type:"function", function:{name, arguments}, index})
LLM_Stream-->>Dispatcher: response.completed
Dispatcher-->>Consumer: Completed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
llm_agents/llm_utils/package.json(1 hunks)llm_agents/llm_utils/src/index.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
llm_agents/llm_utils/src/index.ts (1)
llm_agents/llm_utils/lib/index.d.ts (4)
GraphAILLMStreamDataCompleted(21-24)GraphAILLMStreamData(25-25)GraphAILLMStreamDataCreate(8-11)GraphAILLMStreamDataProgress(12-20)
| { | ||
| "name": "@graphai/llm_utils", | ||
| "version": "2.0.1", | ||
| "version": "2.0.2", |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Semver: patch bump likely insufficient (potentially breaking TS narrowing).
Introducing another union member with the same discriminant ("response.in_progress") can break consumers relying on type narrowing by type. This warrants at least a minor bump, possibly a major if existing consumer code will error.
If you keep the current top-level union, consider bumping to 3.0.0. If you instead model tool-calls within the existing Progress variant (see suggested refactor in src/index.ts), a minor bump (2.1.0) should suffice.
Apply this diff if you proceed with a minor bump:
- "version": "2.0.2",
+ "version": "2.1.0",Run this to gauge breakage across the monorepo:
Also confirm whether lib artifacts are committed or generated in CI. If committed, ensure the d.ts gets updated:
🏁 Script executed:
#!/bin/bash
# Where do we narrow by type === "response.in_progress" and then assume text-only?
rg -nP --type=ts -C3 '\btype\s*===\s*["\']response\.in_progress["\']'
# Where do we use GraphAILLMStreamData?
rg -nP --type=ts -C3 '\bGraphAILLMStreamData\b'Length of output: 116
🏁 Script executed:
#!/bin/bash
# Check if the compiled types include the new ToolsProgress type
fd -t f index.d.ts | xargs -I{} rg -n 'GraphAILLMStreamDataToolsProgress' {}Length of output: 80
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== search: response.in_progress ==="
rg -n --hidden -S -C3 'response\.in_progress' || true
echo
echo "=== search: GraphAILLMStreamData ==="
rg -n --hidden -S -C3 '\bGraphAILLMStreamData\b' || true
echo
echo "=== search: GraphAILLMStreamDataToolsProgress ==="
rg -n --hidden -S -C3 '\bGraphAILLMStreamDataToolsProgress\b' || true
echo
echo "=== llm_agents/llm_utils/package.json (first 120 lines) ==="
if [ -f llm_agents/llm_utils/package.json ]; then
sed -n '1,120p' llm_agents/llm_utils/package.json || true
else
echo "file not found: llm_agents/llm_utils/package.json"
fi
echo
echo "=== search: ToolsProgress token ==="
rg -n --hidden -S -C3 '\bToolsProgress\b' || true
echo
echo "=== find index.d.ts files ==="
fd -e d.ts index.d.ts || true
echo
echo "=== search index.d.ts for GraphAILLMStreamDataToolsProgress ==="
rg -n --hidden -S '\bGraphAILLMStreamDataToolsProgress\b' || trueLength of output: 16255
Semver: major bump required (3.0.0) — new union variant reuses the same discriminant and is a breaking change
Adding GraphAILLMStreamDataToolsProgress with type "response.in_progress" creates two union members with the same discriminant. I ran ripgrep across the repo and found multiple consumers that narrow on data.type === "response.in_progress" and then assume a text-only response shape — this is a breaking change unless you refactor the shape so progress events remain unambiguous.
Files that need attention
- llm_agents/llm_utils/src/index.ts — adds GraphAILLMStreamDataToolsProgress and updates GraphAILLMStreamData.
- llm_agents/llm_utils/package.json — currently "version": "2.0.2" (must be bumped).
- Consumers that narrow by "response.in_progress" and assume text output (examples):
- agent_filters/stream_agent_filter/src/console.ts
- agent_filters/stream_agent_filter/src/node.ts
- llm_agents/openai_agent/src/openai_agent.ts
- llm_agents/anthropic_agent/src/anthropic_agent.ts
- llm_agents/groq_agent/src/groq_agent.ts
- llm_agents/gemini_agent/src/gemini_agent.ts
- (many corresponding lib/* files also reference the same narrowing)
- Compiled types: llm_agents/llm_utils/lib/index.d.ts does not appear to include the new ToolsProgress type (compiled artifacts not updated / inconsistent with src).
Recommended actions
- If you keep the current top-level union (i.e., add a distinct ToolsProgress variant), this is a breaking API change — bump to 3.0.0:
- "version": "2.0.2",
+ "version": "3.0.0",- If you instead fold tool-calls into the existing Progress shape (so the discriminant remains unique), the change can be non-breaking and a minor bump is sufficient:
- "version": "2.0.2",
+ "version": "2.1.0",- Also ensure compiled artifacts / d.ts files are updated and committed (or omitted) so consumers see consistent types.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "version": "2.0.2", | |
| "version": "3.0.0", |
| "version": "2.0.2", | |
| "version": "2.1.0", |
🤖 Prompt for AI Agents
In llm_agents/llm_utils/package.json around line 3, the package version is still
"2.0.2" but the new union variant GraphAILLMStreamDataToolsProgress introduces a
breaking discriminant reuse ("response.in_progress"), so either: 1) make the
change explicitly breaking by bumping the package version to "3.0.0" and update
all affected consumer code (listed in the review) to handle the new
ToolsProgress variant, or 2) refactor the types in
llm_agents/llm_utils/src/index.ts to fold tool-call progress into the existing
Progress shape (keeping the discriminant unique) so the API remains
backward-compatible and then bump only a minor version; in either case
regenerate and commit compiled artifacts/lib/index.d.ts so type consumers see
consistent types, and run tests/lint across the listed consumer packages to
ensure their narrowing logic is updated accordingly.
| export type GraphAILLMStreamDataToolsProgress = { | ||
| type: "response.in_progress"; | ||
| response: { | ||
| output: { | ||
| data: { | ||
| id?: string; | ||
| type?: "tool_calls"; | ||
| function: { | ||
| arguments: string; | ||
| name: string; | ||
| }; | ||
| index: number; | ||
| }[]; | ||
| }[]; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Align the tools progress item shape with existing output items; move the discriminant to the output level.
Right now, type?: "tool_calls" is on the inner data item, while output items lack a type field, unlike the text variant. This makes narrowing at the item level inconsistent and complicates consumers.
Apply this diff to put the discriminant on the output item and make it required:
export type GraphAILLMStreamDataToolsProgress = {
type: "response.in_progress";
response: {
output: {
+ type: "tool_calls";
data: {
id?: string;
- type?: "tool_calls";
function: {
arguments: string;
name: string;
};
index: number;
}[];
}[];
};
};If the upstream payload uses a different container key than data (e.g., tool_calls), adjust accordingly. Please verify the upstream event shape.
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "----- Showing llm_agents/llm_utils/src/index.ts (first 300 lines) -----"
sed -n '1,300p' llm_agents/llm_utils/src/index.ts || true
echo
echo "----- Searching for GraphAILLMStreamData* types -----"
rg -n --hidden --no-ignore -S "GraphAILLMStreamData" || true
echo
echo "----- Searching for occurrences of 'tool_calls' -----"
rg -n --hidden --no-ignore -S "tool_calls" || true
echo
echo "----- Searching for 'response.in_progress' occurrences -----"
rg -n --hidden --no-ignore -S "response.in_progress" || true
echo
echo "----- Searching for other progress variants (text, audio, etc.) to compare shape -----"
rg -n --hidden --no-ignore -S "GraphAILLMStreamData.*Progress|\"text\"|\"response.in_progress\"" || trueLength of output: 285314
Move the discriminant to the output item and make it required (tool_calls)
Confirmed: the current tools progress type puts type?: "tool_calls" on the inner data item while the text progress puts type: "text" on the output item. This is inconsistent and prevents straightforward narrowing. Update the tools progress shape to place a required type: "tool_calls" on the output item and remove the optional type from the inner data.
Files to update
- llm_agents/llm_utils/src/index.ts — update GraphAILLMStreamDataToolsProgress (see diff).
- Note: streaming code emits tool-calls as an output item (e.g. llm_agents/openai_agent/src/openai_agent.ts uses
{ type: "tool_calls", data: ... }), so make sure the types match emitted events. - If you publish built types, regenerate/update llm_agents/llm_utils/lib/index.d.ts (or run the build) after the change.
Apply this diff:
export type GraphAILLMStreamDataToolsProgress = {
type: "response.in_progress";
response: {
output: {
+ type: "tool_calls";
data: {
id?: string;
- type?: "tool_calls";
function: {
arguments: string;
name: string;
};
index: number;
}[];
}[];
};
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export type GraphAILLMStreamDataToolsProgress = { | |
| type: "response.in_progress"; | |
| response: { | |
| output: { | |
| data: { | |
| id?: string; | |
| type?: "tool_calls"; | |
| function: { | |
| arguments: string; | |
| name: string; | |
| }; | |
| index: number; | |
| }[]; | |
| }[]; | |
| }; | |
| }; | |
| export type GraphAILLMStreamDataToolsProgress = { | |
| type: "response.in_progress"; | |
| response: { | |
| output: { | |
| type: "tool_calls"; | |
| data: { | |
| id?: string; | |
| function: { | |
| arguments: string; | |
| name: string; | |
| }; | |
| index: number; | |
| }[]; | |
| }[]; | |
| }; | |
| }; |
🤖 Prompt for AI Agents
In llm_agents/llm_utils/src/index.ts around lines 25 to 40, the
GraphAILLMStreamDataToolsProgress type currently places an optional type?:
"tool_calls" on each inner data item which is inconsistent with text progress
(which uses type: "text" on the output item); change the shape so the output
item has a required property type: "tool_calls" and remove the optional type
from the inner data objects (keep id, function, name, arguments, index as
before); after updating the source type, regenerate or update the built
declaration file (llm_agents/llm_utils/lib/index.d.ts) by running the project
build so emitted types match runtime events.
| export type GraphAILLMStreamData = | ||
| | GraphAILLMStreamDataCreate | ||
| | GraphAILLMStreamDataProgress | ||
| | GraphAILLMStreamDataCompleted | ||
| | GraphAILLMStreamDataToolsProgress; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Duplicate discriminant ("response.in_progress") breaks narrowing; prefer a single Progress variant with a union over output items.
With both Progress and ToolsProgress using type: "response.in_progress", data.type === "response.in_progress" no longer narrows to a single shape, potentially breaking existing code that assumes text-only items.
Two options:
- Recommended: Fold tools progress into
GraphAILLMStreamDataProgressby makingresponse.outputa union of item types (text | tool_calls), and removeGraphAILLMStreamDataToolsProgressfrom the top-level union. - Alternative: Add another discriminator at the top level (e.g.,
variant: "text" | "tools"), but only if it reflects real payloads; avoid inventing fields that don't exist.
Apply this diff to keep a single top-level progress variant:
export type GraphAILLMStreamData =
| GraphAILLMStreamDataCreate
| GraphAILLMStreamDataProgress
- | GraphAILLMStreamDataCompleted
- | GraphAILLMStreamDataToolsProgress;
+ | GraphAILLMStreamDataCompleted;Then update GraphAILLMStreamDataProgress (outside this hunk) to accept both item kinds:
// replace the current output type with a union of items
type GraphAILLMOutputTextItem = {
type: "text";
text: string;
};
type GraphAILLMOutputToolCallsItem = {
type: "tool_calls";
data: {
id?: string;
function: { arguments: string; name: string };
index: number;
}[];
};
export type GraphAILLMStreamDataProgress = {
type: "response.in_progress";
response: {
output: (GraphAILLMOutputTextItem | GraphAILLMOutputToolCallsItem)[];
};
};If you must keep GraphAILLMStreamDataToolsProgress, consider a major version bump (see package.json comment) and provide helper type guards for consumers. I can add those if helpful.
Before merging, please search for code paths that assume only text outputs after narrowing by "response.in_progress":
🏁 Script executed:
#!/bin/bash
rg -nP --type=ts -C3 '\btype\s*===\s*["\']response\.in_progress["\']'Length of output: 116
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "PWD: $(pwd)"
file="llm_agents/llm_utils/src/index.ts"
if [[ -f "$file" ]]; then
echo "=== Showing $file (lines 1-400) ==="
sed -n '1,400p' "$file" || true
else
echo "=== $file not found; searching for files containing GraphAILLMStreamData ==="
rg -n --hidden -S --no-ignore -C3 'GraphAILLMStreamData' || true
fi
echo
echo "=== Occurrences of literal 'response.in_progress' ==="
rg -n --hidden -S --no-ignore -C3 "response.in_progress" || true
echo
echo "=== Occurrences of type === 'response.in_progress' in TypeScript files ==="
rg -nP --type=ts -C3 "type\s*===\s*['\"]response\.in_progress['\"]" || true
echo
echo "=== Usages of response.output ==="
rg -nP --type=ts -C3 "response\.output" || true
echo
echo "=== Definitions/usages of GraphAILLMStreamDataProgress / GraphAILLMStreamDataToolsProgress ==="
rg -n --hidden -S --no-ignore -C3 "GraphAILLMStreamDataProgress|GraphAILLMStreamDataToolsProgress" || trueLength of output: 18582
Duplicate discriminant ("response.in_progress") — must fix: fold tools progress into the single Progress variant
Short: Both GraphAILLMStreamDataProgress and GraphAILLMStreamDataToolsProgress use type: "response.in_progress". Consumers (e.g. stream agent filters) assume text items (data.response.output[0].text) so the duplicate discriminant breaks narrowing and will cause type/ runtime errors.
Files to update / review:
- llm_agents/llm_utils/src/index.ts
- GraphAILLMStreamDataProgress (currently lines ~15–18)
- GraphAILLMStreamDataToolsProgress (currently lines ~25–29)
- GraphAILLMStreamData union (currently lines ~47–51)
- Consumers that assume text on in_progress:
- agent_filters/stream_agent_filter/src/console.ts (uses data.response.output[0].text)
- agent_filters/stream_agent_filter/src/node.ts (uses data.response.output[0].text)
- Note: llm_agents/llm_utils/lib/index.d.ts currently omits ToolsProgress (built types differ from src) — regenerate after changes.
Recommended change (apply a single top-level progress variant and unionize output items):
export type GraphAILLMStreamData =
| GraphAILLMStreamDataCreate
- | GraphAILLMStreamDataProgress
- | GraphAILLMStreamDataCompleted
- | GraphAILLMStreamDataToolsProgress;
+ | GraphAILLMStreamDataProgress
+ | GraphAILLMStreamDataCompleted;And replace / update the progress shape to accept both item kinds:
type GraphAILLMOutputTextItem = {
type: "text";
text: string;
};
type GraphAILLMOutputToolCallsItem = {
type: "tool_calls";
data: {
id?: string;
function: { arguments: string; name: string };
index: number;
}[];
};
export type GraphAILLMStreamDataProgress = {
type: "response.in_progress";
response: {
output: (GraphAILLMOutputTextItem | GraphAILLMOutputToolCallsItem)[];
};
};Follow-ups:
- Update any code emitting the old ToolsProgress shape to emit tool items inside the unified progress.output array.
- Update consumers to discriminate on item.type (e.g., item.type === "text") instead of only checking data.type === "response.in_progress".
- Rebuild/package to regenerate llm_agents/llm_utils/lib/index.d.ts so declarations match source.
If you prefer to keep GraphAILLMStreamDataToolsProgress as a separate top-level variant, that requires a breaking change (major bump) and adding explicit type guards where consumers currently narrow on response.in_progress.
🤖 Prompt for AI Agents
In llm_agents/llm_utils/src/index.ts around lines 15–29 and 47–51, there are
duplicate discriminants: GraphAILLMStreamDataProgress and
GraphAILLMStreamDataToolsProgress both use type "response.in_progress", which
prevents proper narrowing; replace them with a single
GraphAILLMStreamDataProgress whose response.output is a union of text and
tool_calls item shapes (move tool call data into output array items), update the
GraphAILLMStreamData union to remove the separate ToolsProgress variant, update
any emitters to produce tool items inside progress.response.output, update
consumers (agent_filters/stream_agent_filter/src/console.ts and .../node.ts) to
discriminate on item.type === "text" before accessing item.text, and
rebuild/package to regenerate llm_agents/llm_utils/lib/index.d.ts so
declarations match the new source shape.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
llm_agents/llm_utils/lib/index.d.ts (1)
21-37: Two union members share the same discriminator ("response.in_progress"); narrowing bytypeis no longer sufficientBoth GraphAILLMStreamDataProgress and GraphAILLMStreamDataToolsProgress use type: "response.in_progress". This prevents GraphAILLMStreamData from being a cleanly discriminated union by the top-level type field. Any consumer code that previously narrowed solely on d.type === "response.in_progress" and then assumed a text-only payload will now need additional guards for response.output item types.
Suggestions (pick one):
- Keep both types but provide explicit user-facing type guards in src to make narrowing ergonomic (e.g., check response.output[].type).
- Alternatively, model a single GraphAILLMStreamDataProgress whose response.output item is a union of text | tool_calls, avoiding duplicated in-progress variants.
Potential data-shape question:
- If GraphAI can interleave both text and tool_calls in the same in-progress event (same response.output array), the current separation into two types cannot represent that. Please confirm the stream contract and adjust if mixed outputs are possible.
Example type guards to add in src (not in .d.ts) to restore ergonomic narrowing:
export function isToolsProgress( d: GraphAILLMStreamData ): d is GraphAILLMStreamDataToolsProgress { return d.type === "response.in_progress" && Array.isArray((d as any).response?.output) && (d as any).response.output.every((o: any) => o?.type === "tool_calls"); } export function isTextProgress( d: GraphAILLMStreamData ): d is GraphAILLMStreamDataProgress { return d.type === "response.in_progress" && Array.isArray((d as any).response?.output) && (d as any).response.output.every((o: any) => o?.type === "text"); }If mixed outputs can occur in the same event, prefer a single in-progress type with a union of output items:
type GraphAITextOutput = { type: "text"; text: string }; type GraphAIToolCall = { id?: string; type: "function"; function: { arguments: string; name: string }; index?: number; // consider optional if the upstream spec allows }; type GraphAIToolCallsOutput = { type: "tool_calls"; data: GraphAIToolCall[] }; export type GraphAILLMStreamDataProgress = { type: "response.in_progress"; response: { output: (GraphAITextOutput | GraphAIToolCallsOutput)[] }; };Optional check on fields:
- Consider confirming whether data[].index is always present in your stream payloads; if not, mark it optional to avoid downstream parsing issues.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
llm_agents/llm_utils/lib/index.d.ts(1 hunks)llm_agents/llm_utils/package.json(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- llm_agents/llm_utils/package.json
🧰 Additional context used
🧬 Code Graph Analysis (1)
llm_agents/llm_utils/lib/index.d.ts (1)
llm_agents/llm_utils/src/index.ts (2)
GraphAILLMStreamData(48-52)GraphAILLMStreamDataCreate(11-14)
| response: object; | ||
| }; | ||
| export type GraphAILLMStreamData = GraphAILLMStreamDataCreate | GraphAILLMStreamDataProgress | GraphAILLMStreamDataCompleted; | ||
| export type GraphAILLMStreamData = GraphAILLMStreamDataCreate | GraphAILLMStreamDataProgress | GraphAILLMStreamDataCompleted | GraphAILLMStreamDataToolsProgress; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Adding ToolsProgress to GraphAILLMStreamData may be a breaking type change for consumers
Widening GraphAILLMStreamData to include GraphAILLMStreamDataToolsProgress can cause TypeScript compile-time breaks where code previously narrowed on d.type === "response.in_progress" and then accessed text-only fields. This kind of type change typically warrants at least a minor (often major) version bump and a clear CHANGELOG note.
Action items:
- Verify whether this change is intended to be non-breaking. If breaking for typical consumers, consider bumping the major version or at least documenting the change prominently.
- Audit internal handlers that switch on .type and assume text-only output for in-progress events.
Run this script to sanity-check consistency and find potentially impacted sites:
I can help draft a migration note or provide codemods/type guards if we confirm this is intended to be released under the current version.
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Verify src also declares GraphAILLMStreamDataToolsProgress:"
rg -n -C2 --type=ts 'export type GraphAILLMStreamDataToolsProgress' llm_agents/llm_utils/src || echo "Missing in src"
echo
echo "Verify GraphAILLMStreamData union in src includes ToolsProgress:"
rg -n -C1 --type=ts 'export type GraphAILLMStreamData\s*=' llm_agents/llm_utils/src | sed -n '1,200p'
echo
echo "Search for switches on .type that branch on response.in_progress:"
rg -nP --type=ts -C2 '(?s)\bswitch\s*\([^)]*\.type\)[\s\S]*?case\s*[\'"]response\.in_progress[\'"]\s*:' -g '!**/dist/**' -g '!**/lib/**' || true
echo
echo "Search for potential text-only assumptions in progress handlers:"
rg -nP --type=ts -C2 '\bresponse\.output\[\s*0\s*\]\.text\b' -g '!**/dist/**' -g '!**/lib/**' || true
echo
echo "Show llm_utils package.json version(s):"
fd -tf package.json llm_agents/llm_utils | while read -r f; do
echo "==> $f"
rg -n '^\s*"version"\s*:\s*"' "$f" || true
doneLength of output: 1222
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== llm_agents/llm_utils/lib/index.d.ts (first 200 lines) ==="
sed -n '1,200p' llm_agents/llm_utils/lib/index.d.ts || true
echo
echo "=== llm_agents/llm_utils/src/index.ts (first 300 lines) ==="
sed -n '1,300p' llm_agents/llm_utils/src/index.ts || true
echo
echo "=== GraphAILLMStreamData union in src ==="
rg -nP --type=ts "export type GraphAILLMStreamData\s*=" llm_agents/llm_utils/src -C3 || true
echo
echo "=== Occurrences of literal 'response.in_progress' across repo (excluding lib/dist) ==="
rg -n --hidden -S "response.in_progress" -g '!**/dist/**' -g '!**/lib/**' || true
echo
echo "=== Occurrences of response.output[0].text (approx matches) ==="
rg -nP --hidden '\bresponse\.output\[\s*0\s*\]\.text\b' -g '!**/dist/**' -g '!**/lib/**' || true
echo
echo "=== llm_agents/llm_utils/package.json version ==="
if [ -f llm_agents/llm_utils/package.json ]; then
echo "==> llm_agents/llm_utils/package.json"
rg -n '"version"\s*:' llm_agents/llm_utils/package.json || true
else
echo "No package.json at llm_agents/llm_utils/package.json"
fiLength of output: 8704
Public API exposes GraphAILLMStreamDataToolsProgress — breaking/type mismatch detected
Short summary: llm_agents/llm_utils/lib/index.d.ts widens GraphAILLMStreamData to include GraphAILLMStreamDataToolsProgress (tool_calls in in_progress events), while llm_agents/llm_utils/src/index.ts does not include that union member. Consumers that narrow on data.type === "response.in_progress" and then read response.output[0].text will break.
Evidence / locations to inspect
- llm_agents/llm_utils/lib/index.d.ts
- export type GraphAILLMStreamData = GraphAILLMStreamDataCreate | GraphAILLMStreamDataProgress | GraphAILLMStreamDataCompleted | GraphAILLMStreamDataToolsProgress;
- llm_agents/llm_utils/src/index.ts
- GraphAILLMStreamDataToolsProgress is declared, but GraphAILLMStreamData union only contains:
export type GraphAILLMStreamData =
| GraphAILLMStreamDataCreate
| GraphAILLMStreamDataProgress
| GraphAILLMStreamDataCompleted
- GraphAILLMStreamDataToolsProgress is declared, but GraphAILLMStreamData union only contains:
- Consumers that assume text-only in-progress events:
- agent_filters/stream_agent_filter/src/console.ts:7 — console.log(data.response.output[0].text);
- agent_filters/stream_agent_filter/src/node.ts:7 — process.stdout.write(String(data.response.output[0].text));
- Other emitters of response.in_progress you should audit:
- llm_agents/openai_agent/src/openai_agent.ts
- llm_agents/groq_agent/src/groq_agent.ts
- llm_agents/gemini_agent/src/gemini_agent.ts
- llm_agents/anthropic_agent/src/anthropic_agent.ts
- Package version: llm_agents/llm_utils/package.json -> "2.0.3"
Action items
- Confirm intended public API:
- If ToolsProgress is intended to be public: update src union to include GraphAILLMStreamDataToolsProgress (to keep source and lib consistent), audit/fix callers that assume text-only (add runtime/type guards checking output.type === "text"), and treat this as a breaking change — bump the major version and add a clear CHANGELOG/migration note.
- If not intended: remove ToolsProgress from lib (or fix the build) so published types remain unchanged.
- Recommended quick fixes for callers: replace direct accesses like data.response.output[0].text with a safe guard (e.g., check data.response.output[0].type === "text" before reading .text) or add a type guard helper.
I can draft the CHANGELOG/migration note or a small codemod/type-guard snippet if you confirm which direction to take.
Summary by CodeRabbit
New Features
Chores