Skip to content

feat(j5): add a tool to join an existing native thread to a Squadron #129

Closed

Description

@Jacksondr5

Posted by an AI agent on Jackson's behalf.

Outcome

Add a supported tool for an existing, unregistered agent thread to join an explicitly selected Squadron without replacing the thread or losing its conversation. Jackson wants to assign this to a separate agent so the current upstream-integration conversation can acquire a Squadron home and spawn independently reviewable Peer Agents.

Suggested minimal agent-facing surface: join_squadron(squadron_id, client_request_id?), acting on the authenticated calling thread. Naming can follow existing conventions. The operation must be callable by a thread that has no Squadron home: requiring existing membership would defeat its purpose.

Concrete blocked case

Thread Merge 2, 251cd6ea-cc8c-4dd2-90e8-20bd18c7c804, was created through mobile and has no registered home. Its project ID is 689d7294-f022-4d92-9f5a-d0550c4460aa.

list_participants returns A2ASenderNotJoinedError. The maintainer wants this existing conversation assigned to the J5 Code Squadron so its agent can use the participant directory, peer messaging, and spawn_agent. Resolve the actual Squadron ID and owning environment explicitly; the name here is context, not authorization to guess between duplicate names.

This thread was never registered or retired. It does not need legacy archived-agent recovery.

Required behavior

  • Select an existing Squadron explicitly. Validate it against the thread's project/workspace relationship on the owning environment; do not infer membership from the folder, sidebar position, or a matching name.
  • Use the authenticated caller identity and existing Registrar/ledger services to establish the original home and current participation. Make placement/provenance consistent and truthful; do not invent a spawner or fork parent for a previously native thread.
  • Preserve the same thread, provider conversation/session, worktree, messages, and running work. Joining a Squadron must not create another thread, inject a task, or interrupt/restart the current agent merely to establish membership.
  • Make registration atomic or safely recoverable with durable retry identity. Repeating the same successful assignment is harmless; a retry cannot create duplicate registration/placement facts or a new identity.
  • Return the committed Squadron, participant, and thread IDs. Membership reads and peer tools must then observe the new home without manual database edits.
  • Provide a supported way to obtain the explicit Squadron ID, such as the existing authenticated Squadron directory or user selection. list_participants alone cannot bootstrap this because it currently rejects unregistered callers.
  • Refuse conflicting existing homes and deleted/retired targets. A thread already in the requested Squadron can return its existing registration; this is not a cross-Squadron move or retirement-revival tool.

Implementation starting points

Inspect the current J5 base, including:

  • apps/server/src/j5/a2a/HomeRegistrar.ts: original-home registration and conflict handling.
  • SquadronThreadCreationService.ts: existing project-reference validation and creation-time composition.
  • SpawnCompositionService.ts and PlacementService.ts: coordinated membership/placement and truthful provenance.
  • mcp/tools.ts, mcp/handlers.ts, and authenticated MCP registration tests: tool exposure and caller validation.
  • SquadronHttp.ts: existing authenticated Squadron directory.

Registration currently occurs through creation paths. Do not misrepresent an existing-thread join as another thread-creation event or solve this with ad hoc live SQL.

Acceptance

  • An authenticated active native thread with no home can join the explicitly selected compatible Squadron.
  • Its thread ID, conversation, workspace, and running session remain intact.
  • It appears in list_participants, can send messages, and can spawn a registered Peer Agent after joining.
  • Repeated calls, concurrent retries, and partial failure do not create duplicate or conflicting homes/placement.
  • Incompatible project/environment, conflicting existing home, and retired/deleted identity are rejected clearly.
  • Focused tests exercise real registration and authenticated tool dispatch, including the previously unregistered caller case.

Keep this small and independently reviewable. No cross-Squadron moves, legacy retired-agent revival, archive/delete redesign, bulk backfill, upstream merge, or mandatory new UI is part of this issue. #128 separately fixes the mobile creation flow so future threads start with a home; #40 tracks broader mobile parity. This tool repairs the missing supported path for existing native threads.

Prepared with GPT-6 in the Codex harness.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions