Skip to content

Conversation

@WSXYT
Copy link

@WSXYT WSXYT commented Dec 21, 2025

feat: improve error handling and configuration in core and shared services

  • Add warnings and errors for missing chat model candidates or configurations in chat-switcher.

  • Refine OpenAI provider configuration with simplified retry and retryDelay keys and improved initialization logic.

  • Enhance proxy agent configuration with timeout support.

  • Update SharedProvider to bind runtime configurations dynamically for methods (chat, model, etc.), including base URL and API key support.

  • Add and update models (nemotron-3-nano-30b-a3b), adjust aliases, and modify resource definitions in the shared model index.

  • Improve heartbeat processor to handle missing selected models and null LLM raw responses gracefully.
    feat: add Toon format support for prompts and templates

  • Implement support for Toon format in prompt rendering and parsing.

  • Add new Toon-specific templates and partials (output.toon.mustache, agent.user.events.toon.mustache).

  • Enhance prompt service to dynamically select format based on configuration.

  • Introduce ToonParser utility for parsing Toon format responses.

  • Update Config to include PromptFormatConfig for format selection.

  • Log detailed parsing issues for improved troubleshooting.
    toon可谓是十分有潜力,加开关了所以自由切换,我相信在长对话一定可以省不少

- Implement support for Toon format in prompt rendering and parsing.
- Add new Toon-specific templates and partials (`output.toon.mustache`, `agent.user.events.toon.mustache`).
- Enhance prompt service to dynamically select format based on configuration.
- Introduce `ToonParser` utility for parsing Toon format responses.
- Update `Config` to include `PromptFormatConfig` for format selection.
- Log detailed parsing issues for improved troubleshooting.
…vices

- Add warnings and errors for missing chat model candidates or configurations in `chat-switcher`.
- Refine OpenAI provider configuration with simplified `retry` and `retryDelay` keys and improved initialization logic.
- Enhance proxy agent configuration with timeout support.
- Update `SharedProvider` to bind runtime configurations dynamically for methods (`chat`, `model`, etc.), including base URL and API key support.
- Add and update models (`nemotron-3-nano-30b-a3b`), adjust aliases, and modify resource definitions in the shared model index.
- Improve heartbeat processor to handle missing selected models and null LLM raw responses gracefully.
Copilot AI review requested due to automatic review settings December 21, 2025 15:06
@coderabbitai
Copy link

coderabbitai bot commented Dec 21, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for a new "Toon" format for prompts alongside the existing JSON format, while also improving error handling and configuration across core services and providers. The PR introduces a configurable prompt format system that allows switching between JSON and Toon formats, which is claimed to be more token-efficient for long conversations.

Key changes include:

  • Introduction of ToonParser utility for parsing Toon format responses with detailed logging
  • Addition of PromptFormatConfig to enable format selection between JSON and Toon
  • Simplification of OpenAI provider configuration with renamed keys and refactored initialization
  • Enhanced error handling in chat-switcher and heartbeat processor with better logging

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
plugins/provider-openai/src/index.ts Simplified config keys (retry, retryDelay), removed local baseURL normalization, and refactored to use createOpenAI for provider initialization
packages/shared-model/src/utils.ts Added 30-second connection timeout to proxy agent configuration
packages/shared-model/src/index.ts Refactored runtime method binding to dynamically inject baseURL and apiKey for each model method call
packages/shared-model/resources/model-index.json Added nemotron-3-nano-30b-a3b model, relocated and renamed qwen3-235b model from "Venice Large 1.1" to "Qwen3-235B-A22B"
packages/core/src/shared/utils/toon-parser.ts Implemented new ToonParser class to parse Toon format with code block extraction and line-by-line parsing logic
packages/core/src/shared/utils/index.ts Exported ToonParser for use in other modules
packages/core/src/services/prompt/service.ts Enhanced render method to support format-specific template selection and partial mapping based on promptFormat config
packages/core/src/services/prompt/config.ts Added PromptFormatConfig interface and schema with union type for "json" or "toon" format selection
packages/core/src/services/model/service.ts Changed provider registration to log info instead of throwing error when provider already exists
packages/core/src/services/model/chat-switcher.ts Added warning/error logs for missing candidate models and configuration retrieval failures
packages/core/src/services/horizon/chat-mode/default-chat.ts Registered Toon-specific templates with try-catch blocks to gracefully handle missing templates
packages/core/src/config.ts Integrated PromptFormatConfig into main config schema
packages/core/src/agent/heartbeat-processor.ts Integrated ToonParser, improved null handling for model responses, enhanced validation with detailed error logging
packages/core/resources/templates/partials/output.toon.mustache Added Toon format output template with specific formatting requirements
packages/core/resources/templates/agent.user.events.toon.mustache Added Toon format user events template with structured conversation history

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 23 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

WSXYT and others added 9 commits December 23, 2025 21:35
河里

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
河里

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
河里

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
嗯~

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
嗯

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@WSXYT
Copy link
Author

WSXYT commented Dec 23, 2025

我觉得又解决了

…condition

fix(event-manager): simplify data handling in record method

refactor(service): remove unnecessary history cleanup on format change
@WSXYT
Copy link
Author

WSXYT commented Dec 23, 2025

我觉得又又解决了:D

1. 数据库存储逻辑变更 (event-manager.ts)

  • 变更前:在写入数据库时,根据配置(如 toon)将数据预先转换成特定格式的字符串。这导致数据库被特定展示逻辑污染,且格式切换时数据不兼容。
  • 变更后record 方法现在统一将数据作为 标准 JSON 字符串 存入数据库。
    • 无论配置如何,数据库里存的永远是原始结构化数据。
    • 读取时(query 方法)会自动将 JSON 解析回对象,供程序使用。

2. 移除历史记录清理逻辑 (service.ts)

  • 变更前:检测到 Prompt 格式变更(如从 default 切到 toon)时,会强制清空数据库,因为旧格式的数据无法在新模式下使用。
  • 变更后:移除了清空逻辑。
    • 因为现在存的是通用 JSON,切换配置只会改变“如何展示数据”,而不会影响“数据本身”。
    • 用户可以在不同格式间自由切换,无需丢失历史记忆。

3. 动态 Prompt 模板渲染 (default-chat.ts)

  • 变更前:硬编码使用了默认的 Mustache 模板。如果配置了 toon 模式,虽然数据处理了,但模板可能还是用的旧的,导致发给模型的数据格式混乱。
  • 变更后:实现了模板的动态选择。
    • 根据 isToon 标志,自动选择 agent.user.events.toonagent.user.events 模板。
    • 同时动态加载对应的 partials(如 identity.toon 等)。
    • 这确保了模型最终看到的 Prompt 是根据当前配置,由原始 JSON 数据实时渲染出的正确格式。

@WSXYT
Copy link
Author

WSXYT commented Dec 26, 2025

提示词应该已经和json的一致了:D

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