Skip to content

refactor(core): fix sameModel tautology, add query limits, deduplicate agent name lookup#31436

Open
Sylchi wants to merge 2 commits into
anomalyco:devfrom
Sylchi:perf/compounding-performance-fixes
Open

refactor(core): fix sameModel tautology, add query limits, deduplicate agent name lookup#31436
Sylchi wants to merge 2 commits into
anomalyco:devfrom
Sylchi:perf/compounding-performance-fixes

Conversation

@Sylchi

@Sylchi Sylchi commented Jun 8, 2026

Copy link
Copy Markdown

Issue for this PR

N/A — compounding performance issues discovered during code analysis.

Type of change

  • Bug fix
  • Refactor / code improvement

What does this PR do?

Fixes four compounding performance issues:

  1. Bug fix (llm.ts): sameModel(session.model, session.model) compared session.model to itself — always true, making the model inconsistency check dead code. Removed the tautology.

  2. Query limits: Added .limit() to four unbounded queries that grow over time — messageRows in history (500), getAllSessions in stats (1000), Project.list (200), SessionTodo.get (200).

  3. Deduplicated agent name lookup (prompt.ts): The (yield* agents.list()).filter(!hidden).map(name) pattern was copied 5 times. Extracted into a visibleAgentNames helper.

  4. Doom-loop JSON serialization (processor.ts): JSON.stringify(input) was called per-part (3x) instead of once. Pre-computed before the .every() check.

How did you verify your code works?

  • All 23 typecheck tasks pass via turbo
  • All changes are additive limits or pure extractions — no behavioral changes

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

ken added 2 commits June 9, 2026 06:26
…ool message fix

- Add default limits to session listing (50), messages (200), shell
  messages (200), steer promotion (100), and parts query
- Cache context history in llm runner to only fetch deltas between turns
- Switch to selective column queries in history loading
- Add composite indexes for session sort/list queries
- Optimize token estimation to avoid JSON.stringify overhead
- Fix tool result ordering and deduplication in to-llm-message
- Replace structuredClone with JSON.parse/stringify for compat
- Add bench:session script and stale_tomas migration
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

Recommendation: Check PR #31432 to see if there are conflicting or overlapping changes to the same query limits. If that PR is already addressing some of the same performance optimizations, coordinate to avoid duplicate work.

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