feat(stream): add comprehensive streaming module parity with npcpy.streaming#2
Open
celeria-ai[bot] wants to merge 1 commit into
Open
feat(stream): add comprehensive streaming module parity with npcpy.streaming#2celeria-ai[bot] wants to merge 1 commit into
celeria-ai[bot] wants to merge 1 commit into
Conversation
…reaming Add complete streaming module with: - SSE formatting and event utilities - Provider-agnostic chunk parsing (OpenAI, Ollama, llama.cpp) - Message cleaning to fix orphaned tool calls - System prompt management - Tool resolution for jinx, MCP, and Python functions - Tool execution framework - create_chat_stream(): basic streaming without tools - create_tool_agent_stream(): agentic streaming with tool execution loop - create_jinx_stream(): jinx-based agentic streaming - Snake_case aliases for backward compatibility Mirrors npcpy.streaming (~842 lines) for feature parity.
Contributor
Author
There was a problem hiding this comment.
Documentation Gap Assessment
This PR introduces a comprehensive streaming module (~350 lines) but no documentation exists for the new functionality.
Identified Gaps
- README.md - No streaming API documentation for 6 new public exports
- No examples/ - No usage examples for SSE or plain streaming backends
- No parity mapping - Developers familiar with npcpy.streaming have no reference
Code Quality Notes
⚠️ formatMessageForLLM()has incomplete JSDoc (ends with//)⚠️ 350+ lines of new code with no test coverage- ✅ Build passes cleanly
- ✅ Implementation matches npcpy.streaming parity as claimed
Recommendation
Please add before merge:
- README section documenting the streaming API with examples
- JSDoc improvements (fix incomplete
@returnstag) - Tests for the streaming module
Verdict: Code looks correct but docs gap is significant for a "parity" PR that developers will reference.
Full details logged to agent_memory/npc_projects/daily_log/2026-06-10.md.
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
Adds a complete streaming module to npcts that mirrors npcpy's
streaming.pyfor feature parity.What's Added
Core Streaming Infrastructure
formatSSEEvent(),formatSSERaw()with 4096-byte padding for Eventlet/gevent flush compatibilityparseStreamChunk()handles OpenAI, Ollama, llama.cpp, and plain dict formatscleanMessagesForLLM()fixes orphaned tool_calls/tool results that cause API errorsensureSystemPrompt()manages system messages with tool capability awarenessTool Support
resolveNPCTools()resolves jinx catalog, MCP clients, and Python functionsexecuteTool()runs jinx, MCP, and Python tools with proper error handlingaccumulateToolCallDeltas()merges streaming tool_call deltasStreaming Generators
createChatStream(): Basic streaming without tool executioncreateToolAgentStream(): Agentic streaming with tool-calling loop (mutates messages in place)createJinxStream(): Jinx-based agentic streaming loop with checkLLMCommand integrationType Definitions
Full TypeScript interfaces matching Python types:
StreamEvent,ChatMessage,ToolCall,ToolCallDelta,ToolExecutor,ToolSchema,SSEChunk,StreamConfig,ParsedChunk, etc.Backward Compatibility
Snake_case aliases for all camelCase exports matching npcpy naming conventions.
Line Count
~650 lines of TypeScript implementing npcpy.streaming.py (~842 lines of Python).
References