feat(prompt): inject optional system info#79
Conversation
Co-authored-by: GPT-5 Codex <noreply@openai.com>
Co-authored-by: GPT-5 Codex <noreply@openai.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds an optional ChangesSystem Info Prompt Injection
v3.6.4 Version Bump
Sequence Diagram(s)sequenceDiagram
participant Caller
participant PromptBuilder
participant build_prompt_system_info
Caller->>PromptBuilder: build_messages(inputs)
PromptBuilder->>PromptBuilder: read runtime_config.prompt_system_info
PromptBuilder->>build_prompt_system_info: build_prompt_system_info(config)
build_prompt_system_info-->>PromptBuilder: system info text or ""
PromptBuilder->>PromptBuilder: append system message when non-empty
PromptBuilder-->>Caller: messages list
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Undefined/__init__.py`:
- Line 27: The module-level __version__ assignment in __init__.py is missing an
explicit type annotation required by strict mypy checks. Update the __version__
symbol to be explicitly annotated as a string in the same place where the
version constant is defined so the package stays fully type-annotated and
consistent with the coding guidelines.
In `@src/Undefined/ai/prompts/builder.py`:
- Around line 524-537: The system-info gathering in build_messages() is blocking
the async event loop because build_prompt_system_info() and the psutil-based
runtime_config access are called directly inside the coroutine. Move the work
behind asyncio.to_thread() (or another background execution path) in the
self._runtime_config_getter / build_prompt_system_info flow, and keep the
existing logger.debug behavior so the system message append still happens after
the off-thread result is returned.
In `@src/Undefined/ai/prompts/system_info.py`:
- Around line 181-187: The CPU usage line built by _build_cpu_usage_line
currently uses psutil.cpu_percent(interval=None) directly, which can return an
initial baseline 0.0 reading; update this path so the first displayed value is
representative by either priming psutil once at startup or documenting the
baseline behavior, and keep the change localized to _build_cpu_usage_line and
any startup initialization around psutil usage.
- Around line 143-147: The omitted-partition notice in the system info formatter
is calculated from the wrong counter, so it almost never appears. Update the
partition-truncation logic in the function that builds the `lines` list to base
the “其余 … 个分区已省略” count on the total number of partitions being iterated, not on
`seen_mounts`, since `seen_mounts` stops increasing when the loop breaks in the
early-exit path. Keep the existing `max_items` limit behavior, but compute the
skipped count from the full partition collection so the suffix is appended
whenever there are more valid partitions than `max_items`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b3ec1829-6ba3-4371-b637-b7b000492736
⛔ Files ignored due to path filters (5)
apps/undefined-chat/package-lock.jsonis excluded by!**/package-lock.jsonapps/undefined-chat/src-tauri/Cargo.lockis excluded by!**/*.lockapps/undefined-console/package-lock.jsonis excluded by!**/package-lock.jsonapps/undefined-console/src-tauri/Cargo.lockis excluded by!**/*.lockuv.lockis excluded by!**/*.lock
📒 Files selected for processing (22)
CHANGELOG.mdapps/undefined-chat/package.jsonapps/undefined-chat/src-tauri/Cargo.tomlapps/undefined-chat/src-tauri/tauri.conf.jsonapps/undefined-console/package.jsonapps/undefined-console/src-tauri/Cargo.tomlapps/undefined-console/src-tauri/tauri.conf.jsonconfig.toml.exampledocs/configuration.mddocs/message-batching.mdpyproject.tomlsrc/Undefined/__init__.pysrc/Undefined/ai/prompts/builder.pysrc/Undefined/ai/prompts/system_info.pysrc/Undefined/config/__init__.pysrc/Undefined/config/config_class.pysrc/Undefined/config/domain_parsers.pysrc/Undefined/config/load_sections/domains.pysrc/Undefined/config/models.pytests/test_config_api.pytests/test_prompt_builder_message_order.pytests/test_prompt_system_info.py
Co-authored-by: GPT-5 Codex <noreply@openai.com>
Summary
[prompt.system_info]injection for cross-platform host/runtime/resource detailsTests
uv run pytest tests/test_prompt_system_info.py tests/test_prompt_builder_message_order.py tests/test_config_api.py tests/test_config_from_mapping.py tests/test_config_template_sync.pyruff format --check,ruff check,mypySummary by CodeRabbit
prompt.system_info.enabledand control each category (OS, runtime, host, CPU, memory/swap, disks, network, process, uptime).prompt.system_infosection and placement/order notes.