Skip to content

Conversation

@enyst
Copy link
Owner

@enyst enyst commented Oct 4, 2025

Design docs for refactoring the LLM module with a focus on simplicity, readability, and future extensibility (streaming, async, stateful Responses API).

Summary

  • Thin LLM facade with small, focused modules: formatters, options (select_options_*), tools (prep + strategy), transport (litellm boundary), invocation (retry + telemetry), and provider-specific helpers (Anthropic grouping)
  • Model info & capabilities: Extract and cache model_info resolution; pure derivations for token limits and function-calling capability; optional eager init mindful of clone()

Files

  • docs/design/llm-refactor.md
  • docs/design/llm-model-info-and-caps.md

Notes

  • This PR is built on top of another, that's why it has code, but we only work with the .md files here. (we will rebase later)
  • No code behavior changes in this PR, documentation only.
  • Open to feedback on naming and module boundaries before we start small, incremental extractions.

enyst and others added 25 commits October 3, 2025 02:27
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
- Avoid inline import; keep imports at top for clarity

Co-authored-by: openhands <openhands@all-hands.dev>
- Thin LLM facade with focused modules (formatters, options, tools, transport, invokers)
- Future-ready for streaming, async, stateful Responses API
- Extract+cache model_info; pure derivations for token limits and capabilities
- Group Anthropic-specific logic (cache markers, tokens, reasoning) behind small helpers

Co-authored-by: openhands <openhands@all-hands.dev>
@coderabbitai
Copy link

coderabbitai bot commented Oct 4, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch design/llm-refactor-plan

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

enyst added 4 commits October 4, 2025 05:03
…t Anthropic grouping\n\n- clone(): reuse profile only if model/base_url unchanged; otherwise re-resolve\n- LRU cache keyed by (normalized_model, base_url)\n- default http when scheme missing; no extra flags\n\nCo-authored-by: openhands <openhands@all-hands.dev>
…rify Responses path has no Anthropic\n\nCo-authored-by: openhands <openhands@all-hands.dev>
…; keep Chat example minimal\n\nCo-authored-by: openhands <openhands@all-hands.dev>
…ction\n\nCo-authored-by: openhands <openhands@all-hands.dev>
enyst added 2 commits October 4, 2025 06:21
…egments, live switch flow)\n\nCo-authored-by: openhands <openhands@all-hands.dev>
…nfigure of state.agent.llm; no new Agent copies; persistence via base_state save\n\nCo-authored-by: openhands <openhands@all-hands.dev>
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.

3 participants