Skip to content

feat(tarko): support TTFT and TTLT metric#1232

Merged
ulivz merged 30 commits into
mainfrom
feat/add-ttft-display
Aug 26, 2025
Merged

feat(tarko): support TTFT and TTLT metric#1232
ulivz merged 30 commits into
mainfrom
feat/add-ttft-display

Conversation

@ulivz
Copy link
Copy Markdown
Member

@ulivz ulivz commented Aug 22, 2025

Summary

Adds TTFT (Time to First Token) and TTLT (Time to Last Token) support in Agent Kernel

Refs:

Also, add display for assistant messages in the Web UI. Each assistant message now shows response time with color-coded badges indicating performance levels.

Historical Versions

Version 2

image

Version 1

image

Checklist

  • Added or updated necessary tests (Optional).
  • Updated documentation to align with changes (Optional).
  • Verified no breaking changes, or prepared solutions for any occurring breaking changes (Optional).
  • My change does not involve the above items.

@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 22, 2025

Deploy Preview for agent-tars-docs ready!

Name Link
🔨 Latest commit b6c103a
🔍 Latest deploy log https://app.netlify.com/projects/agent-tars-docs/deploys/68adc00d88204c00084b0b05
😎 Deploy Preview https://deploy-preview-1232--agent-tars-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ulivz ulivz force-pushed the feat/add-ttft-display branch from bf53643 to 8446dc2 Compare August 25, 2025 15:11
@ulivz ulivz changed the title feat(tarko): add TTFT display for assistant messages feat(tarko): support TTFT and TTLT Aug 25, 2025
@ulivz ulivz changed the title feat(tarko): support TTFT and TTLT feat(tarko): support TTFT and TTLT metric Aug 25, 2025
@ulivz ulivz force-pushed the feat/add-ttft-display branch from 243d0d1 to f092ecb Compare August 25, 2025 16:08
@ulivz ulivz changed the title feat(tarko): support TTFT and TTLT metric WIP: feat(tarko): support TTFT and TTLT metric Aug 25, 2025
@ulivz ulivz force-pushed the feat/add-ttft-display branch from 3e23615 to 6180f12 Compare August 26, 2025 13:26
ulivz added 23 commits August 26, 2025 21:42
Add timing calculation in agent kernel to populate elapsedMs field:
- Track request start time in LLMProcessor
- Calculate elapsed time from request to response completion
- Set elapsedMs in all assistant_message events
- Handle edge cases (abort, error, max iterations) with 0ms
…play

Improve timing calculation to properly track TTFT vs total response time:
- Track first token time when receiving first content chunk
- Calculate TTFT (Time to First Token) separately from total response time
- Add totalElapsedMs field to event types and UI components
- Enhance TTFTDisplay to show both TTFT and total time when different
- Add detailed timing logs for debugging
- Update tooltip to show timing breakdown
…ards

Update timing field names to use industry-standard terminology:
- elapsedMs → ttftMs (Time to First Token)
- totalElapsedMs → totalResponseTimeMs (clearer naming)
- Add backward compatibility support for elapsedMs
- Update all components to use new field names
- Improve tooltips and documentation with standard terms
- Maintain API compatibility during transition period
Refactor TTFT display to be part of message footer for better UX:
- Extract MessageFooter component from MessageGroup
- Move TTFT display from message content to footer area
- Use subtle colors and smaller size for footer integration
- Maintain left alignment with timestamp and copy functionality
- Remove standalone TTFT display from individual messages
- Improve visual consistency with existing footer elements
- Note: secretlint warnings are false positives for React key props
Simplify TTFT/TTLT metric display by removing separate components:
- Remove LLMMetricDisplay with colors and animations
- Remove MessageTimestamp with mixed responsibilities
- Merge all footer functionality into MessageFooter
- Use consistent gray styling matching timestamp/copy button
- Use ms precision for all time displays instead of s
- Add distinct icons (FiZap for TTFT, FiActivity for TTLT)
- Ensure consistent gray styling for both metrics
- Add clear hover tooltips explaining TTFT and TTLT
- Add cursor-help for better UX indication
- Improve tooltip text with detailed descriptions
- Add position relative to ensure tooltip display
- Replace native title attributes with MUI Tooltip component
- Add arrow prop for better visual indication
- Ensure proper tooltip display across different themes
- Remove cursor-help class to avoid question mark cursor
- Remove arrow prop from MUI Tooltip for cleaner appearance
- Increase font size to 13px for better readability
- Use dark background with white text for higher contrast
- Add padding and shadow for better visual appearance
- Remove arrow prop for cleaner look
- Create tooltipProps constant for shared styling
- Remove duplicate componentsProps definitions
- Maintain consistent appearance across TTFT/TTLT tooltips
- Add back arrow prop for better visual indication
- Use pure black background for higher contrast
- Style arrow to match tooltip background
- Increase shadow opacity for better visibility
- Import and use useDarkMode hook
- Light background with dark text in dark mode
- Dark background with light text in light mode
- Adjust shadow opacity for better visibility
ulivz added 5 commits August 26, 2025 21:42
- Add AgentMetricOptions interface with enable flag (default: false)
- Integrate metric option into AgentOptions via AgentMiscOptions
- Pass enableMetrics flag through AgentRunner to LLMProcessor
- Conditionally collect TTFT/TTLT metrics based on metric.enable setting
- When disabled, timing metrics are not included in event streams
…utations

- Only capture start time when metrics are enabled
- Skip TTFT tracking when metrics are disabled
- Avoid Date.now() calls and timing calculations when not needed
- Reduce logging overhead when metrics collection is disabled
- Ensure zero performance impact when metric.enable = false
@ulivz ulivz force-pushed the feat/add-ttft-display branch from 370b553 to aa9964b Compare August 26, 2025 13:42
@ulivz ulivz changed the title WIP: feat(tarko): support TTFT and TTLT metric feat(tarko): support TTFT and TTLT metric Aug 26, 2025
@ulivz ulivz merged commit bfa2879 into main Aug 26, 2025
10 checks passed
@ulivz ulivz deleted the feat/add-ttft-display branch August 26, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant