Skip to content

feat(llm): configurable SSE buffer caps and profiling tracing coverage#4823

Merged
bug-ops merged 2 commits into
mainfrom
4750-llm-sse-caps-tracing
Jun 5, 2026
Merged

feat(llm): configurable SSE buffer caps and profiling tracing coverage#4823
bug-ops merged 2 commits into
mainfrom
4750-llm-sse-caps-tracing

Conversation

@bug-ops

@bug-ops bug-ops commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

LLM serialization gate

Not applicable — no #[derive(Serialize, Deserialize)] structs, MessagePart, Message, ToolDefinition, or context assembly paths were modified. Changes are limited to compile-time tracing annotations (profiling feature only) and SSE buffer size config (no request/response format changes).

Test plan

Follow-up

Closes #4750, #4808, #4790.

@github-actions github-actions Bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) enhancement New feature or request rust Rust code changes core zeph-core crate size/XL Extra large PR (500+ lines) labels Jun 5, 2026
@bug-ops bug-ops enabled auto-merge (squash) June 5, 2026 14:07
bug-ops added 2 commits June 5, 2026 16:10
…mentation

Closes #4750, #4808, #4790.

- Add `StreamLimits` to `zeph-config` with `max_tool_json_bytes` (4 MiB),
  `max_thinking_bytes` (1 MiB), and `max_compaction_bytes` (32 KiB) defaults.
  Wire through `LlmConfig`, `ClaudeProvider.with_stream_limits()` builder,
  `provider_factory`, and `src/init`. Migration step 56 injects a commented
  `[llm.stream_limits]` hint into existing configs.

- Add `#[cfg_attr(feature = "profiling", tracing::instrument(...))]` to
  `chat_with_tools` on Claude, OpenAI, Gemini, and Compatible providers; to
  `embed_batch` on Compatible; and to all five `LlmProvider` trait methods plus
  `bandit_chat` and `cascade_chat` on `RouterProvider`. Span names follow
  `llm.<provider>.<method>` convention.
…ethods

The 5 LlmProvider impl methods on RouterProvider (chat, chat_stream, embed,
embed_batch, chat_with_tools) return `impl Future` via `Box::pin(async move
{...})`, not `async fn`. A #[tracing::instrument] attribute on such a fn only
wraps the synchronous future-construction call and exits the span before the
future is polled, making the spans no-ops.

Replace the #[cfg_attr(..., tracing::instrument(...))] attributes on those 5
methods with manual span + .instrument() applied to the returned Box::pin
future, guarded by #[cfg(feature = "profiling")]. The two async fn helpers
(bandit_chat, cascade_chat) are correct as-is and unchanged.

Also use section_header_present helper in migrate_llm_stream_limits guard
to match the idempotency pattern introduced by #4812.
@bug-ops bug-ops force-pushed the 4750-llm-sse-caps-tracing branch from 884d4f0 to f9ff9a9 Compare June 5, 2026 14:10
@bug-ops bug-ops merged commit 307ea61 into main Jun 5, 2026
32 checks passed
@bug-ops bug-ops deleted the 4750-llm-sse-caps-tracing branch June 5, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

1 participant