Skip to content

feat(agents): detect OMP / Oh My Pi as a first-class agent - #15

Merged
rsnodgrass merged 1 commit into
mainfrom
feat/omp-detection
Aug 17, 2026
Merged

rsnodgrass merged 1 commit into
mainfrom
feat/omp-detection

Conversation

@rsnodgrass

@rsnodgrass rsnodgrass commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Tools built on agentx can now recognize Oh My Pi (OMP) — a Pi fork that installs under ~/.omp and ships its own omp binary — as a first-class agent instead of misreading it as upstream Pi. This is the agentx counterpart to the ox ox-adapter-omp work (sageox/ox#779): ox currently has to declare OMP as a local constant and bypass agentx's detection gate precisely because agentx didn't know OMP existed.

Approach: add AgentTypeOMP + OMPAgent (detects via the omp binary in the exec path and AGENT_ENV=omp/oh-my-pi), and make the OMP and Pi runtime detectors mutually exclusive so the map-ordered registry never has to break a tie between two forks that share the PI_CODING_AGENT marker.

The one subtlety worth your eyes

OMP inherits Pi's PI_CODING_AGENT env marker from the shared cli.ts ancestry, and the registry stores agents in a map — so List() order is nondeterministic and phase-1 detection has no tiebreak if both runtime detectors fire. Rather than rely on registration order (which guarantees nothing), PiAgent.DetectRuntime now yields when the launching binary is omp, keeping the two detectors mutually exclusive by construction.

Honest limitation, documented in code: a node-launched OMP process that only exports the inherited PI_CODING_AGENT (no omp in _) can still resolve to Pi in phase 1. AGENT_ENV=omp (which the ox integration always sets) or DetectByType is authoritative there.

What changed

File Change
agent.go AgentTypeOMP = "omp" constant + SupportedAgents entry
agents/omp.go New OMPAgent — full Agent interface, ~/.omp config, tail-mode capabilities (no hooks)
agents/pi.go DetectRuntime yields to OMP when the launcher is omp / oh-my-pi
agents/register.go, setup/setup.go Register OMPAgent in both paths
agents/omp_test.go New: detection, mutual-exclusion, metadata, capabilities, install, session
agents/pi_test.go, agent_test.go Pi-guard cases + enumeration updates
CHANGELOG.md [0.1.14]

Test Plan

  • make check — fmt + lint (golangci-lint: 0 issues) + test (1164 tests, 2 skipped, 0 failures)
  • TestOMPDetect — 10 cases incl. the Pi-marker rejections (PI_CODING_AGENT / PI_CODING_AGENT_DIR / AGENT_ENV=pi → not OMP) and substring guard (compose → no match)
  • TestOMPPiMutualExclusion — asserts OMP and Pi never both fire, including the pathological omp launcher + inherited PI_CODING_AGENT
  • TestPiDetect — new cases prove Pi yields to the omp launcher; all prior Pi cases still pass (no regression)
Design notes
  • OMP is not a LifecycleEventMapper and reports Hooks: false: the SageOx integration drives it via native .omp/AGENTS.md guidance and tails its JSONL transcript, not an extension-bridge hook (unlike Pi).
  • SessionID prefers OMP_SESSION_ID, falls back to Pi's PI_SESSION_ID (shared ancestry), else "" (sessions are discovered by file).
  • URL/source (github.com/can1357/oh-my-pi) taken from the ox cmd/ox-adapter-pi/rules.go reference, not invented.

Summary by CodeRabbit

  • New Features

    • Added support for detecting and configuring the Oh My Pi (OMP) coding agent.
    • Added OMP metadata, capabilities, version and installation detection, session tracking, and configuration/context file resolution.
    • Registered OMP in the default supported-agent list.
  • Bug Fixes

    • Improved runtime detection to distinguish OMP from Pi when launcher signals overlap.
    • Prevented Pi from being incorrectly detected when launched through OMP.

Adds AgentTypeOMP and OMPAgent for github.com/can1357/oh-my-pi, a Pi fork
installed under ~/.omp with its own omp binary. Detection uses the omp
binary in the exec path and AGENT_ENV=omp/oh-my-pi.

OMP inherits Pi's PI_CODING_AGENT marker from shared cli.ts ancestry, so
PiAgent.DetectRuntime now yields when the launcher is omp, keeping the two
runtime detectors mutually exclusive by construction (the registry is a map
with no ordering guarantee to break a tie).
@coderabbitai

coderabbitai Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ffd6d706-79c7-4a3f-82b2-3355a920c9c9

📥 Commits

Reviewing files that changed from the base of the PR and between 106797f and 1e69368.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • agent.go
  • agent_test.go
  • agents/omp.go
  • agents/omp_test.go
  • agents/pi.go
  • agents/pi_test.go
  • agents/register.go
  • setup/setup.go

📝 Walkthrough

Walkthrough

Added first-class Oh My Pi support. The change defines the OMP agent, detects OMP runtimes, resolves configuration and context paths, registers the agent, and prevents Pi detection from matching OMP launchers.

Changes

OMP agent support

Layer / File(s) Summary
OMP agent contract and behavior
agent.go, agents/omp.go
Adds AgentTypeOMP and implements OMP metadata, detection, configuration paths, capabilities, manager accessors, installation checks, version detection, and session lookup.
OMP and Pi runtime disambiguation
agents/omp.go, agents/pi.go, agents/omp_test.go, agents/pi_test.go
Detects OMP through executable and environment signals. Excludes OMP launchers from Pi detection. Tests cover mutual exclusion and inherited markers.
Registry integration and validation
agent_test.go, agents/omp_test.go, agents/register.go, setup/setup.go, CHANGELOG.md
Registers OMP in supported and default registries. Tests validate the agent contract and behavior. The changelog documents the feature.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Launcher
  participant OMPAgent
  participant PiAgent
  Launcher->>OMPAgent: provide executable path and AGENT_ENV
  OMPAgent-->>Launcher: detect OMP runtime
  Launcher->>PiAgent: provide executable path and Pi markers
  PiAgent-->>Launcher: reject omp and oh-my-pi launchers
``

</details>

<!-- walkthrough_end -->
<!-- finishing_touch_checkbox_start -->

<details>
<summary>✨ Finishing Touches</summary>

<details>
<summary>📝 Generate docstrings</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> Create stacked PR
- [ ] <!-- {"checkboxId": "3e1879ae-f29b-4d0d-8e06-d12b7ba33d98"} --> Commit on current branch

</details>
<details>
<summary>🧪 Generate unit tests (beta)</summary>

- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Create PR with unit tests
- [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Commit unit tests in branch `feat/omp-detection`

</details>

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---




<sub>Comment `@coderabbitai help` to get the list of available commands.</sub>

<!-- tips_end -->
Loading

@rsnodgrass
rsnodgrass marked this pull request as ready for review August 17, 2026 19:37
@rsnodgrass
rsnodgrass merged commit 6a90422 into main Aug 17, 2026
5 checks passed
@rsnodgrass
rsnodgrass deleted the feat/omp-detection branch August 17, 2026 19:37
@greptile-apps

greptile-apps Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Greptile Summary

This change adds OMP agent metadata, registration, configuration, session behavior, and runtime detection alongside Pi support. Runtime detection incorrectly treats a non-OMP executable as OMP when any parent directory contains oh-my-pi, so the registry selects OMP before reaching the valid Pi fallback. The failure was reproduced with a launcher under an oh-my-pi workspace path; restricting the check to the executable basename selects Pi for the same input.

Confidence Score: 4/5

Not ready to merge until OMP runtime detection identifies the launcher by basename rather than matching arbitrary parent directories.

A focused executable reproduction exercised both the OMP runtime check and registry selection. It showed the current code selecting OMP for an unrelated launcher, while a basename-only predicate selected the configured Pi agent for the identical input.

Files Needing Attention: agents/omp.go needs the runtime predicate corrected and a regression test should cover a non-OMP executable below a directory containing oh-my-pi.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex posted a P1 finding and produced a proof set that includes the associated artifacts.
  • T-Rex performed general-contract-validation-proof work to evaluate the path-matching logic and show how the temporary predicate correction changes behavior from omp_runtime true to omp_runtime false with updated selected_type, demonstrating the interaction between the detector and the path conditions.
  • Artifacts were prepared to support the reviewer, including the full-path reproduction source and the test output logs that accompany the findings.

View all artifacts

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (1)

  1. General comment

    P1 OMP runtime detection treats any path containing oh-my-pi as an OMP executable

    • Bug
      • OMPAgent.DetectRuntime returns true for /srv/oh-my-pi-workspace/bin/non-omp-executable. Because runtime detection is phase one, the registry selects OMP before it reaches the valid lower-priority Pi AGENT_ENV detector.
    • Cause
      • agents/omp.go:83 uses a substring match across the full launcher path: strings.Contains(strings.ToLower(execPath), "oh-my-pi").
    • Fix
      • Match the executable basename instead, e.g. strings.EqualFold(filepath.Base(execPath), "oh-my-pi"), alongside the existing exact omp basename check; add a regression case for a non-OMP executable under a directory containing oh-my-pi.

    T-Rex Ran code and verified through T-Rex

Fix all with Greploop

Fix All in Claude Code

Reviews (1): Last reviewed commit: "feat(agents): detect OMP / Oh My Pi as a..." | Re-trigger Greptile

Comment thread agents/omp.go
Comment on lines +83 to +84
if strings.Contains(strings.ToLower(execPath), "oh-my-pi") {
return true, nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Full-path launcher false positive

DetectRuntime treats any executable whose full path contains oh-my-pi as OMP. A non-OMP launcher at /srv/oh-my-pi-workspace/bin/non-omp-executable therefore wins phase-one detection, preventing the valid Pi environment detector from running and selecting the requested agent. Match oh-my-pi against filepath.Base(execPath) rather than using a substring search over every directory component, and add this path-layout regression case.

Artifacts

Full-path reproduction source

  • The program registers OMP and Pi, supplies the problematic full path plus a Pi override, and invokes runtime and public detector paths, proving the claimed scenario is executable.

Unmodified detection output

  • Running the authored reproducer against the repository code reports `omp_runtime=true` and `selected_type=omp`, showing phase one incorrectly preempts Pi.

Exact-basename comparison output

  • Running the same reproducer after a temporary exact-basename-only predicate reports `omp_runtime=false` and `selected_type=pi`, confirming the narrow cause and expected outcome.

Restoration and focused test output

  • The command confirms the original substring predicate was restored and `go test ./agents` completed successfully, showing no repository source was permanently modified.

View artifacts

T-Rex Ran code and verified through T-Rex

Fix in Claude Code

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