feat: add notificationThrottleMs and notificationMinChunkSize to AbstractAgent - #1420
Closed
mxmzb wants to merge 4 commits into
Closed
feat: add notificationThrottleMs and notificationMinChunkSize to AbstractAgent#1420mxmzb wants to merge 4 commits into
mxmzb wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@ag-ui/a2a-middleware
@ag-ui/a2ui-middleware
@ag-ui/mcp-apps-middleware
@ag-ui/middleware-starter
@ag-ui/a2a
@ag-ui/adk
@ag-ui/ag2
@ag-ui/agno
@ag-ui/aws-strands
@ag-ui/claude-agent-sdk
@ag-ui/crewai
@ag-ui/langchain
@ag-ui/langgraph
@ag-ui/langroid
@ag-ui/llamaindex
@ag-ui/mastra
@ag-ui/pydantic-ai
@ag-ui/server-starter
@ag-ui/server-starter-all-features
@ag-ui/vercel-ai-sdk
create-ag-ui-app
@ag-ui/client
@ag-ui/core
@ag-ui/encoder
@ag-ui/proto
commit: |
…ractAgent Adds two optional throttle knobs to AbstractAgent that coalesce rapid subscriber notifications during streaming: - notificationThrottleMs: time-based cap (e.g. 16ms = ~60fps) - notificationMinChunkSize: character-based cap (e.g. 20 = batch single-char tokens until 20 chars accumulate) When both are set, notification fires when EITHER threshold is hit first. Mutations are always applied immediately (agent.messages stays current); only subscriber notifications are throttled. Default path (no throttle) is the original code, unchanged. Throttle logic lives in a separate private method (processThrottledNotifications). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mxmzb
force-pushed
the
feat/notification-throttle-ms
branch
from
April 2, 2026 15:08
a61367f to
4f2ee00
Compare
Contributor
Python Preview PackagesVersion
Install with uvAdd the TestPyPI index to your [[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
explicit = trueThen install the packages you need: # Core SDK
uv add 'ag-ui-protocol==0.0.0.dev1775146046' --index testpypi
# Integrations (each already depends on the matching ag-ui-protocol preview)
uv add 'ag-ui-langgraph==0.0.0.dev1775146046' --index testpypi
uv add 'ag-ui-crewai==0.0.0.dev1775146046' --index testpypi
# NOTE: ag-ui-agent-spec depends on pyagentspec (git-only, not on PyPI).
# You will need to install pyagentspec separately from its git repo.
uv add 'ag-ui-agent-spec==0.0.0.dev1775146046' --index testpypi
uv add 'ag_ui_adk==0.0.0.dev1775146046' --index testpypi
uv add 'ag_ui_strands==0.0.0.dev1775146046' --index testpypiInstall with pippip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
ag-ui-protocol==0.0.0.dev1775146046
Commit: 1c53b2b |
- Replace flat notificationThrottleMs/notificationMinChunkSize with
grouped NotificationThrottleConfig { intervalMs, minChunkSize? }
- Add input validation (non-negative, finite) with clear error messages
- Make notificationThrottle readonly to prevent mid-run mutation
- Fix type safety: replace `as any` content access with proper
role === "assistant" narrowing (prevents NaN from non-string content)
- Fix charsSinceLastNotify tracking across message boundaries by
tracking message ID and resetting lastContentLength on identity change
- Add try-catch around subscriber calls in notify() to prevent a single
throwing subscriber from crashing the pipeline
- Add disposed flag to prevent timer-fired notifications after stream
teardown
- Fix JSDoc to accurately describe leading-edge + trailing behavior
- Expand test coverage from 3 to 11 tests: state changes, subscriber
errors, clone preservation, input validation, large throttle windows
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wrap subscriber calls in addMessage, addMessages, setMessages, setState, and the throttle finalize flush with try-catch to prevent a single throwing subscriber from blocking others or causing unhandled rejections. Adds test for subscriber error isolation in addMessage path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Superseded by new PR from clean branch (feat/notification-throttle-ms-v2) — original branch had contamination from #1385. |
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AbstractAgentthat coalesce rapid subscriber notifications during streamingnotificationThrottleMs: time-based cap (e.g.16= ~60fps)notificationMinChunkSize: character-based cap (e.g.20= batch single-char tokens until 20 chars accumulate)agent.messages/agent.statestay current); only subscriber notifications are throttledTest plan
onMessagesChanged(1:1)notificationThrottleMs: fewer notifications than chunks, final state completenotificationMinChunkSize: holds notifications until N chars accumulate, final state complete🤖 Generated with Claude Code