Skip to content

fix(brain): restore agent_types/skill_types compat shims dropped in #542 - #621

Merged
theo-michel merged 2 commits into
mainfrom
fix/agent-skill-compat-shims
Aug 7, 2026
Merged

fix(brain): restore agent_types/skill_types compat shims dropped in #542#621
theo-michel merged 2 commits into
mainfrom
fix/agent-skill-compat-shims

Conversation

@theo-michel

Copy link
Copy Markdown
Contributor

Problem

PR #542 deleted brain_client/agent_types.py and brain_client/skill_types.py — the star-import compat shims for the pre-refactor module paths. Every custom agent and skill in the field authored before #542 imports those paths, so after an OS update they all roster as broken with ModuleNotFoundError: No module named 'brain_client.agent_types'. On robot R7-27 that was all 21 custom agents.

Fix

  • Restore both shims verbatim from the pre-feat(skills): Pick Anything Skill + Other changes #542 tree (git show db3e33fe^). Star-import re-export means class identity is preserved, so __init_subclass__ registration, the loader, and isinstance checks work with zero special-casing — the loader doesn't know the shim exists.
  • Export Agent, SkillRef, InputRef from the innate facade so new agents author against the stable public namespace (from innate import Agent) instead of brain_client internals — shims protect the past, the facade protects the future. agents/types.py is import-light (no ROS at module level), so this adds no weight to import innate.
  • Regression tests:
    • test_legacy_and_facade_import_paths_load — an agent authored against the old path and one against innate both load onto the roster (the exact field regression).
    • test_compat_shims.py — both shims re-export the same class objects as the new modules.

Verification

  • ruff check + ruff format --check: clean on all touched files
  • pytest: 44 passed (includes the 3 new tests; the two *.launch.py collection errors on main are pre-existing)
  • basedpyright: 0 errors in touched files (full-repo baseline not reproducible on the Jetson — no stub env)
  • Live on R7-27: discover_agent_classes + build_agent_instances over the real workspace → 0 import errors, 0 broken, 28 agents loaded (21 custom) — previously all 21 custom agents were broken.



PR #542 deleted the brain_client.agent_types and brain_client.skill_types
star-import shims, which every pre-#542 custom agent and skill in the field
imports — after an OS update, all of them roster as broken with
ModuleNotFoundError (all 21 custom agents on R7-27 were down).

Restore both shims verbatim, export Agent/SkillRef/InputRef from the innate
facade so new agents author against the stable namespace, and add regression
tests: the legacy and facade import paths must load an agent onto the roster,
and the shims must re-export the same class objects (registration and
isinstance depend on identity).
@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Restores compatibility for agents and skills authored against the pre-refactor module paths while exposing agent authoring types through the stable innate facade.

  • Adds star-import shims for brain_client.agent_types and brain_client.skill_types, preserving class identity.
  • Exports Agent, SkillRef, and InputRef from innate.
  • Covers both legacy agent rostering and legacy skill workspace discovery with regression tests.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
ros2_ws/src/brain/brain_client/brain_client/agent_types.py Restores the legacy agent-type import path by re-exporting the canonical agent types.
ros2_ws/src/brain/brain_client/brain_client/skill_types.py Restores the legacy skill-type import path by re-exporting the canonical skill types.
ros2_ws/src/brain/brain_client/innate/init.py Adds canonical agent authoring types to the stable public facade without changing their identities.
ros2_ws/src/brain/brain_client/test/test_agent_loading.py Verifies that agents using either the legacy module or public facade are discovered and rostered.
ros2_ws/src/brain/brain_client/test/test_compat_shims.py Verifies identity-preserving exports and exercises a legacy skill through workspace discovery and registration.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  LegacyAgent["Legacy agent<br/>brain_client.agent_types"] --> AgentShim["agent_types shim"]
  FacadeAgent["New agent<br/>innate.Agent"] --> AgentTypes["brain_client.agents.types"]
  AgentShim --> AgentTypes
  LegacySkill["Legacy skill<br/>brain_client.skill_types"] --> SkillShim["skill_types shim"]
  SkillShim --> SkillTypes["brain_client.skills.types"]
  AgentTypes --> AgentDiscovery["Agent discovery and roster"]
  SkillTypes --> SkillDiscovery["Skill workspace discovery"]
Loading

Reviews (2): Last reviewed commit: "test(brain): legacy skill loads end-to-e..." | Re-trigger Greptile

Comment on lines +19 to +30
def test_skill_types_shim_reexports_same_objects():
for name in (
"Skill",
"SkillResult",
"SkillOutput",
"SkillCancelled",
"RobotState",
"RobotStateType",
"Interface",
"InterfaceType",
):
assert getattr(skill_types, name) is getattr(skills_types, name)

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.

P2 Exercise legacy skill discovery

This test checks the skill shim only through direct imports, while legacy custom skills use the workspace discovery and registration path. Adding a dynamic-loading regression like the agent-side test would prevent loader-specific compatibility regressions from passing these identity assertions unnoticed.

Knowledge Base Used: brain_client: agent/skill runtime and ROS bridge

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — added in 6f2bb4d: a legacy-authored skill (old brain_client.skill_types import, class-attribute Interface/RobotState declarations, tuple return) now loads end-to-end through import_workspace_packages + registered_workspace_skills, the same discovery functions _load_code_skills calls. The fixture clears Skill._registry so discovery sees only the synthetic workspace — other test modules register Skills (some deliberately broken), and discovery both rosters and prunes whatever the live registry holds.

Greptile flagged that the skill shim was only covered by direct-import
identity checks while field skills load via discovery. Add a legacy-authored
skill (old import path, Interface/RobotState declarations, tuple return)
loaded through import_workspace_packages + registered_workspace_skills — the
same functions the catalog calls. The fixture clears Skill._registry (other
test modules register Skills, some deliberately broken, and discovery both
rosters and prunes whatever the live registry holds).

@karmanyaahm karmanyaahm 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.

aye

@theo-michel
theo-michel merged commit 92cc729 into main Aug 7, 2026
6 of 7 checks passed
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.

2 participants