Streaming UI Hooks Module
November 10, 2025 ยท View on GitHub
Progressive display for thinking blocks, tool invocations, and token usage in the Amplifier console.
Purpose
Display streaming LLM output (thinking blocks, tool calls, and token usage) to console with configurable formatting and truncation.
Contract
Inputs
content_block:startevents - Detect start of thinking blockscontent_block:deltaevents - Track thinking block progress (not displayed)content_block:endevents - Display complete thinking blockstool:preevents - Display tool invocationstool:postevents - Display tool resultsllm:responseevents - Display token usage statistics
Outputs
- Formatted console output via print statements
- No data transformations or system state changes
Side Effects
- Console output only (print statements to stdout)
Dependencies
amplifier-core- For events, coordinator, and HookResult types- Standard library only (no external dependencies)
Configuration
Configure via profile.ui section:
[ui]
show_thinking_stream = true # Display thinking blocks (default: true)
show_tool_lines = 5 # Max lines to show for tool I/O (default: 5)
show_token_usage = true # Display token usage after each turn (default: true)
Features
- Thinking Block Display: Shows formatted thinking blocks with clear visual boundaries
- Tool Invocation Display: Shows tool name and truncated arguments
- Tool Result Display: Shows success/failure status with truncated output
- Token Usage Display: Shows input/output/total token counts after each LLM response
- Configurable Truncation: Limit tool I/O display to configured line count
- Clean Formatting: Visual separators and icons for better readability
Events Hooked
| Event | Purpose | Action |
|---|---|---|
content_block:start | Detect thinking block start | Display "Thinking..." indicator |
content_block:end | Receive complete thinking block | Display formatted thinking content |
tool:pre | Tool invocation | Display tool name and arguments |
tool:post | Tool result | Display success/failure with output |
llm:response | LLM response received | Display token usage statistics |
Display Format
Thinking Blocks
๐ง Thinking...
============================================================
Thinking:
------------------------------------------------------------
[thinking content here]
============================================================
Tool Invocations
๐ง Using tool: tool_name
Arguments: {truncated arguments}
โ
Tool result: tool_name
{truncated output}
Token Usage
โ Input: 1,234 | Output: 567 | Total: 1,801
โโ ๐ Token Usage
Philosophy Compliance
โ Zero kernel changes - Pure hooks implementation, no core modifications โ Pure observability - Only displays information, no behavior changes โ Configuration via profile - Uses standard profile.ui settings โ Simple, focused implementation - Single responsibility: console display โ Modular design - Self-contained module with clear contract
Testing
Run tests with:
cd amplifier-module-hooks-streaming-ui
pytest tests/
Regeneration Specification
This module can be fully regenerated from this README specification. Key invariants:
- Mount function signature:
async def mount(coordinator, config) - Hook registration on coordinator.hooks
- Return HookResult with action="continue"
- No state changes to system, only console output
- Configuration from profile.ui section
Contributing
Note
This project is not currently accepting external contributions, but we're actively working toward opening this up. We value community input and look forward to collaborating in the future. For now, feel free to fork and experiment!
Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit Contributor License Agreements.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.