Skip to content

Add runtime recording#2573

Merged
openminddev merged 15 commits into
mainfrom
Add-runtime-recording
May 27, 2026
Merged

Add runtime recording#2573
openminddev merged 15 commits into
mainfrom
Add-runtime-recording

Conversation

@YuchengZhou821

Copy link
Copy Markdown
Contributor

This pull request introduces a new runtime data recording feature for OM1, enabling the system to log tick-level data to daily JSONL files. The main changes include the implementation of the RuntimeRecorder class, integration of recording logic into the runtime, configuration support for enabling/disabling the recorder, and comprehensive tests to ensure correct behavior.

Runtime Data Recording Feature

Implementation and Integration:

  • Added the RuntimeRecorder class (src/runtime/recorder.py) to record runtime tick data (including timestamps, ASR input, LLM input/output, and actions) to daily JSONL files, with automatic file rotation and robust error handling.
  • Integrated the recorder into the runtime lifecycle in src/runtime/cortex.py: initializes the recorder when enabled, records tick data in _tick, and ensures proper cleanup on shutdown. [1] [2] [3] [4] [5]

Configuration and Data Management:

  • Added a recorder field to the runtime config (src/runtime/config.py, src/runtime/converter.py), allowing the feature to be enabled/disabled via configuration, and ensured correct propagation through config loading and serialization. [1] [2] [3] [4]
  • Updated docker-compose.yml to mount a host directory for storing recordings.

Testing:

  • Added a comprehensive test suite for RuntimeRecorder (tests/runtime/test_recorder.py), covering directory creation, tick recording, file rotation, error handling, and persistence.
  • Added tests for recorder config passthrough and default behavior in the config converter tests.

These changes provide a robust and configurable mechanism to record and persist runtime activity, supporting future analysis and debugging.

Copilot AI review requested due to automatic review settings May 14, 2026 23:00
@YuchengZhou821 YuchengZhou821 requested review from a team as code owners May 14, 2026 23:00
@github-actions github-actions Bot added robotics Robotics code changes python Python code infrastructure Docker/Infrastructure tests Test files config Configuration files labels May 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an optional runtime recorder that writes tick-level runtime data to JSONL files for later debugging and analysis.

Changes:

  • Adds RuntimeRecorder for daily JSONL recording.
  • Integrates recorder setup, tick recording, and shutdown cleanup into the runtime.
  • Adds config passthrough, Docker volume mounting, and recorder-focused tests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/runtime/recorder.py Adds JSONL runtime tick recorder with daily file rotation.
src/runtime/cortex.py Wires recorder lifecycle and per-tick recording into the runtime loop.
src/runtime/config.py Adds recorder field to runtime configuration loading/serialization.
src/runtime/converter.py Preserves recorder setting when converting single-mode configs.
tests/runtime/test_recorder.py Adds unit tests for recorder creation, writing, rotation, stopping, and restart append behavior.
tests/runtime/test_convert.py Adds converter tests for recorder passthrough/default behavior.
docker-compose.yml Mounts a host recordings directory into the container.

Comment thread src/runtime/cortex.py Outdated
Comment thread src/runtime/config.py Outdated
@codecov

codecov Bot commented May 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.68293% with 6 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/providers/tracer.py 94.44% 3 Missing ⚠️
src/llm/plugins/functiongemma.py 0.00% 2 Missing ⚠️
src/llm/plugins/openrouter.py 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread src/recorder/__init__.py Outdated
from datetime import datetime, timezone
from typing import Any

enable_recording = os.environ.get("OM1_ENABLE_RECORDING", "false").lower() == "true"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should come from the config file

Introduce a Recorder singleton (providers/recorder.py) to centralize LLM interaction logging to daily-rotated JSONL files. Replace the old module-level recorder with the new provider: initialize Recorder in LLM and cortex, switch LLM plugins to call self.recorder.record(...), and use recorder.set_generation(...) in runtime/cortex.py. Add comprehensive unit tests (tests/providers/test_recorder.py) and remove the legacy src/recorder module and its tests. The Recorder supports enable/disable, generation tracking, atexit cleanup, and safer error handling when writing records.
Rename providers/recorder.py -> providers/tracer.py and replace Recorder with Tracer (method record -> gauge, default output_dir changed to "traces"). Update imports and usages across the codebase: llm/__init__.py, all llm plugins (deepseek, functiongemma, gemini, near_ai, ollama, openai, openrouter, qwen, xai) now use self.tracer.gauge instead of self.recorder.record. Wire Tracer into runtime: runtime.cortex uses Tracer, ModeCortexRuntime enables tracing when mode_config.tracing is set, and set_generation now calls tracer.set_generation. Expose tracing in configuration: runtime.config and ModeSystemConfig gain a tracing field; converter and load_mode_config now propagate the tracing flag. Tests updated: removed tests/providers/test_recorder.py and added tests/providers/test_tracer.py with equivalent checks for the new Tracer behavior.
Remove the OM1_ENABLE_RECORDING environment variable (previously defaulted to false) and replace the host volume ${HOME}/recorded_data/recordings with a repository-relative ./traces mounted to /app/OM1/traces. This moves recorded data into the project directory; update any host-side data paths or backup/migration procedures accordingly.
Move the ${HOME}/shared_data/locations and ./traces volume mounts earlier in the service's volumes list and remove their original entries. This groups local project mounts with config and cyclonedds mounts for clearer ordering and readability.
Replace the old tracing flag with use_tracer across runtime modules. Updated ModeSystemConfig and RuntimeConfig docs/fields, changed load_mode_config to read use_tracer from raw config and pass it through, adjusted ConfigConverter mapping, and updated cortex to check mode_config.use_tracer when enabling the tracer. Note: existing configs that use "tracing" should be updated to "use_tracer".
Set use_tracer: true in conversation config to enable tracing for the conversation service. Add 'traces' to .gitignore to prevent trace output from being committed.
Update runtime version and all configuration/test metadata to v1.0.5. This commit increments latest_runtime_version in src/runtime/version.py, updates version fields across numerous config JSON5 files and integration test cases, and adjusts tests/docs to expect v1.0.5 so code, tests, and documentation remain consistent with the new release.
@openminddev openminddev requested a review from a team as a code owner May 27, 2026 22:04
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 27, 2026
@openminddev openminddev merged commit 8061dd9 into main May 27, 2026
8 checks passed
@openminddev openminddev deleted the Add-runtime-recording branch May 27, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration files documentation Improvements or additions to documentation infrastructure Docker/Infrastructure python Python code robotics Robotics code changes tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants