Skip to content

refactor(core): add query limits, context caching, indexed queries, and tool message fix#31432

Open
Sylchi wants to merge 1 commit into
anomalyco:devfrom
Sylchi:perf/session-query-limits-caching
Open

refactor(core): add query limits, context caching, indexed queries, and tool message fix#31432
Sylchi wants to merge 1 commit into
anomalyco:devfrom
Sylchi:perf/session-query-limits-caching

Conversation

@Sylchi

@Sylchi Sylchi commented Jun 8, 2026

Copy link
Copy Markdown

Issue for this PR

N/A — performance improvements discovered during code analysis.

Type of change

  • Refactor / code improvement

What does this PR do?

Adds query limits across session listing, messages, shell messages, steer promotion, and parts to prevent unbounded queries on large sessions. Adds a context cache in the LLM runner so only delta history entries are fetched between turns instead of re-loading everything. Switches to selective column queries in history loading and adds composite indexes for common session sort/list patterns. Fixes tool result ordering and deduplication in to-llm-message.ts. See commit diff for full list.

How did you verify your code works?

  • All 23 typecheck tasks pass via turbo
  • Changes are additive (adding limits, caching, indexes) and should not break existing behavior
  • The tool message ordering fix aligns the output with the intended behavior (tool results after their calls, no duplicates)

Screenshots / recordings

N/A

Checklist

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

…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 added needs:title needs:compliance This means the issue will auto-close after 2 hours. labels Jun 8, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title perf(core): add query limits, context caching, indexed queries, and tool message fix doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@Sylchi Sylchi changed the title perf(core): add query limits, context caching, indexed queries, and tool message fix refactor(core): add query limits, context caching, indexed queries, and tool message fix Jun 8, 2026
@github-actions github-actions Bot removed needs:title needs:compliance This means the issue will auto-close after 2 hours. labels Jun 8, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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