perf(tui): cut render delay by deferring provider and memory - #157
Merged
Conversation
Building the agent loop eagerly imported litellm (~2-7s) and the everos/lancedb memory backend (~2.1s) on the render path, so `raven tui` showed an empty shell for 4-5s before real content. - LazyProvider wraps the real provider so litellm loads on first chat, with a background prewarm thread; wired via make_lazy_provider for the TUI only. A cheap credential check preserves startup fail-fast without importing litellm. - EverosBackend defers its adapter import into start(), which the TUI now runs in the background after the render handshake; recall and store degrade to empty until it is ready. Render drops from 4-5s to ~1-2s with real tool and skill counts. Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
The intro row rendered an empty body between the wordmark and the session.info handshake (~1-2s). Show a StartupLoader in that gap: a braille spinner in the same rounded box as SessionPanel, with a label that steps through the bring-up stages. It is replaced by SessionPanel the moment info arrives, so there is no residual height. Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
The prettier-ui-tui hook checks the whole src tree on any ui-tui change; `useMainApp.ts` carried a pre-existing drift from #80 that this branch is the first ui-tui change to trip. Reformat it so CI is green. Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
cyfyifanchen
approved these changes
Jul 19, 2026
12 tasks
cyfyifanchen
added a commit
that referenced
this pull request
Jul 19, 2026
## Summary Bump Raven package metadata from 0.1.5 to 0.1.6 so the release tag can build a wheel from the current main branch. This release carries the changes merged after v0.1.5: - Version display now derives from installed package metadata (#139). - Tracing dashboard port reuse avoids taking over non-Raven viewers (#141). - CLI startup defers LiteLLM imports for faster cold start (#147). - Self-evolution stack and AppWorld benchmark entry points are included (#140). - TUI render delay is reduced by deferring provider and memory loading (#157). ## Type - [ ] Fix - [ ] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [x] Other ## Verification - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots are updated when needed Commands run: - `PYTHONPATH=. uv run pytest tests/test_cli_smoke.py::test_version_flag_matches_installed_metadata -q` - `make check-commits COMMIT_RANGE=origin/main..HEAD` - `PYTHONPATH=. uv run python scripts/check_commit_file.py /tmp/raven-commit-msg.txt` No user-facing docs or screenshots were needed for this version metadata bump; release notes will be published with the GitHub Release. ## Risk - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes This changes package metadata only. Rollback is to delete the v0.1.6 tag/release if publication fails before users upgrade, or publish a follow-up patch release if a released package issue is found. ## Related Issues N/A
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
Profiling
raven tuibring-up put the agent-loop build(
_build_tui_agent_loop) at ~7s, so the TUI showed an empty shellfor several seconds before real content (issue #128 reports it as a
4-5s delay). Two eager imports on that path dominated: litellm when
the loop built its provider, and the everos/lancedb memory backend
(its
start()measured ~2.5s). Deferring both off the render pathdrops the build to ~1.8s -- the diffuse-import residual -- and a
startup loader fills what remains.
perf:LazyProviderdefers litellm to the first chat (with abackground prewarm);
EverosBackenddefers its adapter import intostart(), which the TUI runs in the background after the renderhandshake. recall/store degrade to empty until the backend is ready.
A cheap credential check keeps startup fail-fast without importing
litellm.
feat(tui): aStartupLoader(braille spinner in the SessionPanelbox) fills the pre-handshake gap and is replaced by the real panel
the moment
session.infoarrives.The empty-shell window drops from ~7s to ~1-2s, with real tool/skill
counts and no
-32008on the first send.Non-blocking trade-offs (documented, not bugs): the residual ~1.8s is
diffuse imports with no single lever; quitting within the first ~2.5s
waits briefly on the background backend task; a first message sent
within ~2.5s runs one turn without memory recall (silent degrade).
Phase-timing startup logs (one of the issue's acceptance items) were
not added -- the delay was root-fixed rather than instrumented.
Also reformats
useMainApp.ts(a pre-existing drift from #80) so thewhole-tree prettier hook passes on this first ui-tui change since.
Type
Verification
Commands:
make lint-python,make test-python, andcd ui-tui && npm run lint && npm run type-check && npm test && npm run build.Risk
Provider swap on model change still works (the loop holds a plain
assignable provider attribute). agent/gateway paths keep
make_provider;only the TUI uses the lazy path.
Related Issues
Fixes #128