fix(agent): faster purchasing run, clean rationale, no silent hangs#5
Open
eugnmueller-87 wants to merge 1 commit into
Open
fix(agent): faster purchasing run, clean rationale, no silent hangs#5eugnmueller-87 wants to merge 1 commit into
eugnmueller-87 wants to merge 1 commit into
Conversation
Three UX/perf fixes for the weekly purchasing screen:
1. Parallelize the run. It made one LLM call PER product, serially (~60s+).
Split the copilot's sourcing call into signal-gather (DB, main thread) and
the LLM call (pure network) so the network calls fire in a thread pool —
collapsing N round-trips into ~one. The public recommend_sourcing stays the
single mockable seam (now accepts pre-gathered signals); all copilot mocks
updated to match. Decisions are unchanged — only the wall-clock.
2. Strip the debug prefix from rationale. Cards showed the raw
"[trigger] {evidence} | net_need=N | bundle_tier=X |" justification. The
audit log keeps the full string; the UI now shows only the human rationale.
3. No more silent hangs. api() gains an optional timeout (AbortController);
the run (90s) and insights (60s) use it and show an error+Retry instead of
spinning forever when an LLM call stalls.
Tests: 310 pass, ruff clean, frontend syntax clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes three issues you spotted on the weekly purchasing screen.
1. The run was slow (~60s+) — now parallel
It made one LLM call per product, serially. Split the copilot's sourcing call into signal-gather (DB, main thread) + the LLM call (pure network), so the network calls fire in a thread pool — N round-trips collapse into ~one.
recommend_sourcingstays the single mockable seam (accepts pre-gatheredsignals); all copilot mocks updated. Decisions are unchanged — only wall-clock.2. Debug text leaked into the cards
Rationale showed the raw
[trigger] {evidence dict} | net_need=N | bundle_tier=X |prefix. The audit log keeps the full string; the UI now shows only the human rationale (cleanRationale).3. Silent hangs
api()gains an optional timeout (AbortController); the run (90s) and insights (60s) use it and show an error + Retry instead of spinning forever when an LLM call stalls.Note on the original 'can't place escalated items'
That was the €50k escalate threshold — already fixed in the merged PR #4 (€150k → these become
propose/approvable). This PR is the other three issues.Verification
Demo-first.