feat(agents): add provider-neutral orchestration - #5632
Closed
megascan wants to merge 21 commits into
Closed
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
This PR adds a provider-neutral Agents and Rules system to T3 Code. It is one end-to-end product feature spanning contracts, persistence, server orchestration, MCP, all five provider adapters, web/desktop, mobile, migrations, tests, and documentation.
Current size: 141 files, 18,461 additions, and 86 deletions. This exceeds automated approvability limits and requires careful human review; the passing correctness checks should not be mistaken for approval of a diff this large.
Suggested labels:
enhancement,documentation,size:XXL,needs-triage,preview:web, andcodex. The fork author does not have upstream triage permission, so GitHub only applied the labels available to its automation.Agent profiles and Rules
chatSelectabledistinguishes direct-chat Agents from delegation-only specialists. Existing pinned threads retain their Agent even if it is later hidden from new chats.t3.jsonreferences contained to the canonical project root; the catalog does not recursively scan repositories.Durable orchestration
AgentRundomain, append-only events, transactional projections, immutable profile snapshots, lineage queries, revision waits, deadlines, usage, results, follow-ups, cancellation, and integration.T3-owned Agent tools
Providers receive the same portable MCP toolkit:
agent_listagent_spawnagent_statusagent_waitagent_resultagent_sendagent_cancelagent_integrateTools are scoped to the invoking T3 project, thread, lineage, and run ownership. Launch is asynchronous and returns a durable run ID; result reads are bounded and paginated.
Provider-neutral boundary
Shared and isolated workspaces
git apply --check --3way, and then applies it.Web, desktop, mobile, and remote behavior
Why
ACP is a clean provider transport, but an ACP provider does not inherently know that it is running inside T3 and cannot reliably orchestrate another provider. Provider-native subagent systems also differ in naming, policy, lifetime, and availability.
This puts orchestration in the layer that has the required context: T3. A user can chat with an inexpensive coordinator, delegate architecture or implementation to specialized models, and keep every child run inspectable as an ordinary T3 thread without coupling core behavior to OpenGrok, GrokBuild, or any single provider.
UI evidence
Before: no Agent settings surface
After: first-party profile and Rule management
The selected specialist is marked delegation only. The host identifier is redacted from the public evidence image.
After: searchable picker beside the model picker
Search filters direct-chat profiles immediately. Delegation-only specialists remain available through orchestration but are absent from new top-level chat choices.
After: selected Agent shown in the composer
After: native Agent run in the parent Agents panel
After: file-aware Rules
Short picker interaction recording
Evidence is published on a separate fork branch so binary review artifacts do not enter the product diff.
Verification
EPERM.git diff --check: passed.1062149af.1062149af.Integrated browser coverage used an isolated
.t3environment and exercised:src/**/*.{ts,tsx}across save and reload;Honest scope and known limitations
chatSelectablecontrols discovery, not authorization. Delegation policy and provider compatibility remain execution gates..shmock-wrapper limitations on this Windows host. The complete OpenCode file hits the existing privileged-symlinkEPERMlimitation. The new provider assertions pass directly; Linux CI remains authoritative for those complete files.afterResultparticipates in the durable success decision and provider events must stay ordered per thread. A future optimization requires a keyed bounded scheduler with explicit drain and shutdown semantics.t3McpCapabilitiesis compatibility metadata, not an ACL.Checklist
Implemented with GPT-5.6 Sol through the Codex harness in T3 Code.
Note
Add provider-neutral agent orchestration with profile/rule management and MCP tool surface
AgentOrchestrationservice interface,AgentRunRepositoryfor durable event storage,AgentRunReactor/AgentRunDeadlineReactorfor state management and wall-time budget enforcement, andAgentPromptResolverfor profile-aware prompt compilation.AgentProfileStoreandAgentRuleStorefor filesystem-backed, revision-checked persistence of agent profiles and rules in Markdown+YAML frontmatter format, coordinated viaAgentProjectFileCoordinatorto avoid races.agents.catalog,agents.getProfile,agents.saveProfile,agents.archiveProfile,agents.restoreProfile, and rule equivalents) with scope-appropriate auth enforcement.agent_*MCP tools (agent_spawn,agent_wait,agent_result,agent_send,agent_cancel,agent_integrate, etc.) gated on a new'agents'MCP capability granted by default to all sessions./settings/agents) and mobile (SettingsAgents) apps, including catalog browsing, draft editing, save/archive/restore, and environment/project scoping.agent_profile_snapshots,projection_agent_runs,agent_run_eventstables and addingagent_profile_jsontoprojection_threads.'agents'capability by default; existing credential checks for'preview'are unaffected but all sessions gain access to agent tools without explicit opt-in.Macroscope summarized 502d128.
Note
Medium Risk
Changes thread bootstrap and outbox schema (agent profile pinning) and adds large new settings/orchestration surfaces; incorrect revision or selection merging could mis-pin agents on turns, though logic is covered by focused tests.
Overview
Mobile adds an Agents entry under Settings (stack route
agents) with a new screen to pick environment/project context, browse profile and rule catalogs, create and edit drafts, and save/archive/restore via existingagentEnvironmentRPC atoms. Supporting modules (agentProfile.logic,agentRule.logic,agentSettings.logic) handle document building, revision-safe hydration, and optimistic selection after saves.Composer flows now expose an Agent toolbar menu on new-task and thread composers. Choices are limited to chat-selectable profiles (with delegation-only profiles still visible when already pinned). Selecting a profile can apply its default model;
AgentProfileRefis stored on composer drafts, queued outbox messages, andthread.turn.start/ thread-creation bootstrap payloads, with explicit “No agent” preserved viaresolveAgentProfileSelection.Server (partial in this diff) introduces read-only AgentCatalog (environment Markdown dirs + explicit
t3.jsonproject refs, bounded RPC lists), AgentHookRunner for staged context/shell hooks, the AgentOrchestration service boundary, and orchestration lifecycle/integration test coverage; the orchestration integration harness stubs AgentPromptResolver when profiles are unused.Reviewed by Cursor Bugbot for commit 502d128. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit