inspecting-streams
Skill0 starsChanged 6 months agoMITView on GitHub
Inspects the raw token stream a real LLM emits for a given system + user prompt, with chunk boundaries preserved. Use when debugging dense / unformatted model output (run-on text, missing newlines, glued-on emoji), validating that a system-prompt change produces the markdown structure you expected, or comparing two prompts / models side-by-side without spinning up the agentic loop or any tools.
- Reads credentials
In this repository65 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/building-agents/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- adding-guardrailsSkill
- agent-health-timeoutSkill
- agent-permission-scopingSkill
- agent-session-isolationSkill
- agent-step-loggingSkill
- agent-supervisor-routerSkill
- agent-telemetrySkill
- async-agent-backgroundSkill
- building-agentsSkill
- building-teamsSkill
- building-toolsSkill
- calendar-scheduling-toolSkill
- callback-tracing-handlerSkill
- chain-of-thought-promptingSkill
- chat-model-configurationSkill
- code-execution-sandboxSkill
- common-agent-patternsSkill
- context-window-managementSkill
- conversation-memorySkill
- conversation-state-dbSkill
- database-query-toolSkill
- document-loadersSkill
- document-rerankingSkill
- email-notification-toolSkill
- embedding-model-ingestionSkill
- fallback-model-chainSkill
- few-shot-injectionSkill
- filesystem-toolSkill
- human-in-the-loopSkill
- hybrid-searchSkill
- integrating-with-laurenSkill
- json-schema-enforcementSkill
- llm-provider-connectionSkill
- llm-rate-limitingSkill
- long-term-vector-memorySkill
- managing-memorySkill
- migrating-to-lauren-aiSkill
- multi-agent-delegationSkill
- multi-tool-orchestrationSkill
- multi-turn-tool-stateSkill
- output-guardrailsSkill
- plan-and-execute-agentSkill
- prompt-injection-defenseSkill
- prompt-versioningSkill
- rag-pipelineSkill
- react-agent-loopSkill
- response-validation-retrySkill
- rest-api-toolSkill
- securing-agentsSkill
- semantic-cacheSkill
- streaming-response-handlerSkill
- structured-output-parsingSkill
- sub-agent-spawningSkill
- system-prompt-templatingSkill
- testing-agentsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 103
Don't use this to test agent behaviour end-to-end: Use AgentTestClient (see testing-agents skill) for that — it covers tools, hooks, …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Use
codemap find "SymbolName"to locate any symbol before reading — it gives exact file + line range and is faster than grep across the whole repo.
Inspecting LLM Streams
When to use
You added a "use blank lines between paragraphs" directive to your agent's
system prompt and want proof the model now emits \n\n between sentences.
You have a chat UI that renders messages as run-on text and you suspect the
model itself is the source rather than the renderer. You want to compare
how two models (Claude 3.5 Sonnet vs. a free open-source model) handle the
same prompt structurally.
In all these cases you want the raw token deltas from the transport,
not an aggregated Completion object — chunk boundaries reveal what the
model actually emitted versus what your wire format / parser preserved.
What it does
inspect_stream.py calls a transport's complete(..., stream=True)
directly, prints each chunk.delta with repr() (so \n shows
explicitly), then prints the full accumulated text and a count of
newlines. No agent loop, no tool calls, no SSE framing — just LLM input
→ LLM output.
--- STREAMED CHUNK DELTAS (repr'd, \n preserved) ---
'Here'
' are'
' the'
' details'
':'
'\n\n'
'-'
' **'
'Recipient'
'**:'
' Bob'
...
--- FULL ACCUMULATED TEXT ---
Here are the details:
- **Recipient**: Bob
...
--- BACKSLASH-N COUNT: 6 -- TOTAL LEN: 91 ---Running the script
# Set transport credentials (Anthropic / OpenAI / OpenRouter all work).
export OPENROUTER_API_KEY=sk-or-v1-...
export LLM_MODEL="poolside/laguna-xs.2:free"
uv run python skills/inspecting-streams/inspect_stream.py \
--system "You are a banking assistant. Use blank lines between paragraphs and put each list item on its own line." \
--prompt "Summarise the products SecureBank offers."Or import the helper into a one-off REPL session:
import asyncio
from skills.inspecting_streams.inspect_stream import trace
from lauren_ai import LLMConfig
cfg = LLMConfig.for_anthropic(model="claude-haiku-4-5")
asyncio.run(trace(cfg, system="You are a poet.", user_prompt="Write three lines about the sea."))Interpreting the output
'\\n\\n'between chunks → the model is emitting paragraph breaks. Renderer should produce real paragraphs.' '(single space) where you expected'\\n'→ the model is treating the boundary as a soft break. Either tighten the system prompt's formatting directive or accept the result.-followed immediately by content with no preceding'\\n'→ the model is jamming list items onto the same line as the heading. System-prompt fix: show a concrete bullet-list example.- Trailing
' \\n'(two spaces + newline) → CommonMark hard line break. GFM renders this as<br>; harmless but worth noting.
Why bypass the agent loop
The agentic loop adds tool execution, hooks, signal emission, and
sometimes a follow-up turn. When you only want to know "what does this
model emit for this exact prompt", those layers obscure the picture.
This skill reaches past AgentRunner.run_stream straight to
Transport.complete(..., stream=True) for the cleanest signal.
Anti-patterns
- Don't use this to test agent behaviour end-to-end. Use
AgentTestClient(seetesting-agentsskill) for that — it covers tools, hooks, multi-turn flows, and assertions. - Don't add ad-hoc whitespace heuristics on the renderer side because
this script shows dense output. Fix the system prompt. Renderer
heuristics inevitably misfire on legitimate identifiers
(
SecureBank,OAuth,GitHub) that look structurally identical to missing-space sentence boundaries.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

