Skip to content

[BUG] MUT-021: Second project load can reuse the first project's agent module #69

Closed

Description

@CodewithJha

Problem

Loading project B after project A in one process: from agent import VALUE in B’s adapter still resolved to A’s agent.py (sys.modules cache). Confirmed in audit: B factory returned "A". Sample AGENT_REF = "agent:support_agent" makes this the default module name.

Why it matters

Low for one-shot CLI. High for tests, notebooks, or any in-process multi-project runner. Wrong agent silently under test.

Evidence

  • Audit ID: MUT-021 (MEDIUM, confirmed).
  • packages/mutiny_openai_agents/src/mutiny_openai_agents/loader.py ensure_project_on_path + importlib.import_module.
  • Audit: two temp projects loaded sequentially; second factory returned the first project’s value.

Reproduction

Audit in-process sequential load. Not independently re-run in this filing pass; loader still uses bare import_module(module_name) on current main.

Expected behavior

Each project root loads its own agent module (or uniquely named modules). Loading B after A returns B’s factory.

Suggested implementation direction

Unique module names per project root, or isolate/pop sys.modules entries you loaded. Avoid breaking AGENT_REF = "agent:support_agent" for one-shot CLI.

Acceptance criteria

  • Sequential load of two temp projects with agent.py returning different markers yields the second project’s marker.
  • Sample mutiny run / mutiny test still work.
  • Unit test in adapter loader tests.
  • No change to Hosted observe-only (does not load customer adapters).

Scope

mutiny_openai_agents/loader.py (+ tests). Out of scope: demo_agent process globals (MUT-046, skipped — Hosted concurrency=1).

Related audit findings

MUT-021. Related skipped: MUT-046.

Contributor notes

Generated from the Mutiny deep audit.

help wanted.

Activity

  1. added
    bugSomething isn't working
    help wantedExtra attention is needed
    priority:P1Important reliability/adoption
    adaptersTargetAdapter / framework adapters
    on Sep 24, 2026
  2. BasilZafar11 commented on Oct 11, 2026

    @BasilZafar11
    Contributor

    Opened PR #119 to fix this issue. Sequential project loads now resolve the correct agent and clear stale project imports. Added seven regression tests; all 663 tests pass.

    #119

  3. added a commit that references this issue on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    adaptersTargetAdapter / framework adaptersbugSomething isn't workinghelp wantedExtra attention is neededpriority:P1Important reliability/adoption

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions