Skip to content

fix(ai-harness): infer HarnessAgentsOf from properties to avoid a TS 7.1 circularity - #1913

Open
grantila wants to merge 1 commit into
TanStack:mainfrom
grantila:fix/ai-harness-agents-of-ts71-circularity
Open

grantila wants to merge 1 commit into
TanStack:mainfrom
grantila:fix/ai-harness-agents-of-ts71-circularity

Conversation

@grantila

@grantila grantila commented Oct 26, 2026 •

Copy link
Copy Markdown

🎯 Changes

Under TypeScript 7.1, defineHarness() and host.open() fail with:

TS2615 ("Type of property 'agents' circularly references itself in mapped type 'Pick<SessionImpl<…>, PublicSessionMember>'").

TypeScript 7.0 accepts the same code.

Cause: HarnessAgentsOf infers the agents by matching the whole HarnessDefinition. That definition holds session: SessionWithMetadata<…>, whose agents: AgentHandles<THarness> remaps keys through HarnessAgentsOf again. TS 7.1 reports the loop.

Fix: HarnessAgentsOf now infers from the agents and subagents.agents properties only. The result type is unchanged. A type test checks it for a harness with agents and subagents, with only agents, with neither, and for AnyHarness.

🎯 Changes

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.
  • Docs: I updated docs/ for this change, or this change is not user-facing.
  • Changeset: I added a changeset (pnpm changeset), or this PR does not change a published package.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed TypeScript 7.1 compilation errors affecting harness definition and opening workflows.
    • Preserved existing inferred agent types, including agents configured directly or through subagents. When no agents are configured, the inferred type remains empty.

…7.1 circularity

Under TypeScript 7.1, defineHarness() and host.open() fail with TS2615
("Type of property 'agents' circularly references itself in mapped type
'Pick<SessionImpl<…>, PublicSessionMember>'"). HarnessAgentsOf matched the
whole HarnessDefinition, whose session reaches AgentHandles, which remaps
keys through HarnessAgentsOf again. Read agents and subagents.agents alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f1266ad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/ai-harness Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-26T13:33:05.539881Z f1266ad PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: TanStack/ai
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 8731d75
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b178c875-99cb-47a3-b7b3-0d2667934205
Commits

Reviewing files that changed from the base of the PR and between 8731d75 and f1266ad.

Files selected for processing: 3
  • .changeset/harness-agents-of-ts71.md
  • packages/ai-harness/src/define.ts
  • packages/ai-harness/tests/types.test-d.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

HarnessAgentsOf now extracts agent types from agents and subagents.agents directly. Type assertions cover both properties, agents-only harnesses, harnesses without agents, and AnyHarness. A patch changeset describes the update.

Changes: Harness agent types

Layer / File(s) Summary
Agent extraction and type validation
packages/ai-harness/src/define.ts, packages/ai-harness/tests/types.test-d.ts, .changeset/harness-agents-of-ts71.md
HarnessAgentsOf infers agent types from agents and subagents.agents. Type assertions cover both properties, absent agents, and AnyHarness. The changeset describes the TypeScript 7.1 TS2615 report and the type-resolution change.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: alemtuzlak

Merge Risk: Minimal · up to f1266

No actionable issue remains in the reviewed change. It is ready to merge after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the main change: HarnessAgentsOf now infers from properties to fix a TS 7.1 circularity. It uses the fix(ai-harness) scope and matches the raw summary and PR objectives. It is specific…
Description check Passed The description covers the change and the reason for it. It names the TS2615 error, the cause in HarnessAgentsOf, the fix, and the new type test. The checklist is filled in. The template's first '## 🎯…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: HarnessAgentsOf now infers from properties to fix a TS 7.1 circularity. It uses the fix(ai-harness) scope and matches the raw summary and PR objectives. It is specific and descriptive, so it passes.

Full details: Description check

Explanation

The description covers the change and the reason for it. It names the TS2615 error, the cause in HarnessAgentsOf, the fix, and the new type test. The checklist is filled in. The template's first '## 🎯 Changes' heading is followed by the author's content, and the template placeholder comment and a duplicate '## 🎯 Changes' heading remain. The author did not fill in the 'Release Impact' section beyond ticking the changeset box, which is consistent with the changeset file. The description is mostly complete, so it passes. Minor cleanup is suggested.

Resolution

Remove the duplicate '## 🎯 Changes' heading and the leftover template comment in the description. Optionally state the docs decision in the checklist, since no docs change is listed.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.)

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit f1266ad

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 7m 17s View ↗
nx run-many --targets=test:coverage --projects=... ✅ Succeeded 4s View ↗
nx run-many --targets=build --exclude=examples/... ✅ Succeeded 1m 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-10-27 11:47:20 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/@tanstack/ai@1913

@tanstack/ai-acp

npm i https://pkg.pr.new/@tanstack/ai-acp@1913

@tanstack/ai-angular

npm i https://pkg.pr.new/@tanstack/ai-angular@1913

@tanstack/ai-anthropic

npm i https://pkg.pr.new/@tanstack/ai-anthropic@1913

@tanstack/ai-bedrock

npm i https://pkg.pr.new/@tanstack/ai-bedrock@1913

@tanstack/ai-byteplus

npm i https://pkg.pr.new/@tanstack/ai-byteplus@1913

@tanstack/ai-claude-code

npm i https://pkg.pr.new/@tanstack/ai-claude-code@1913

@tanstack/ai-client

npm i https://pkg.pr.new/@tanstack/ai-client@1913

@tanstack/ai-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-cloudflare@1913

@tanstack/ai-code-mode

npm i https://pkg.pr.new/@tanstack/ai-code-mode@1913

@tanstack/ai-code-mode-snippets

npm i https://pkg.pr.new/@tanstack/ai-code-mode-snippets@1913

@tanstack/ai-codex

npm i https://pkg.pr.new/@tanstack/ai-codex@1913

@tanstack/ai-cohere

npm i https://pkg.pr.new/@tanstack/ai-cohere@1913

@tanstack/ai-compaction

npm i https://pkg.pr.new/@tanstack/ai-compaction@1913

@tanstack/ai-computer-local

npm i https://pkg.pr.new/@tanstack/ai-computer-local@1913

@tanstack/ai-computer-playwright

npm i https://pkg.pr.new/@tanstack/ai-computer-playwright@1913

@tanstack/ai-computer-sandbox

npm i https://pkg.pr.new/@tanstack/ai-computer-sandbox@1913

@tanstack/ai-computer-use

npm i https://pkg.pr.new/@tanstack/ai-computer-use@1913

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/@tanstack/ai-devtools-core@1913

@tanstack/ai-durable-stream

npm i https://pkg.pr.new/@tanstack/ai-durable-stream@1913

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@1913

@tanstack/ai-event-client

npm i https://pkg.pr.new/@tanstack/ai-event-client@1913

@tanstack/ai-fal

npm i https://pkg.pr.new/@tanstack/ai-fal@1913

@tanstack/ai-gemini

npm i https://pkg.pr.new/@tanstack/ai-gemini@1913

@tanstack/ai-grok

npm i https://pkg.pr.new/@tanstack/ai-grok@1913

@tanstack/ai-grok-build

npm i https://pkg.pr.new/@tanstack/ai-grok-build@1913

@tanstack/ai-groq

npm i https://pkg.pr.new/@tanstack/ai-groq@1913

@tanstack/ai-harness

npm i https://pkg.pr.new/@tanstack/ai-harness@1913

@tanstack/ai-harness-cli

npm i https://pkg.pr.new/@tanstack/ai-harness-cli@1913

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@1913

@tanstack/ai-isolate-daytona

npm i https://pkg.pr.new/@tanstack/ai-isolate-daytona@1913

@tanstack/ai-isolate-e2b

npm i https://pkg.pr.new/@tanstack/ai-isolate-e2b@1913

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/@tanstack/ai-isolate-node@1913

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@1913

@tanstack/ai-isolate-quickjs-bun

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs-bun@1913

@tanstack/ai-llmgateway

npm i https://pkg.pr.new/@tanstack/ai-llmgateway@1913

@tanstack/ai-lovable

npm i https://pkg.pr.new/@tanstack/ai-lovable@1913

@tanstack/ai-mcp

npm i https://pkg.pr.new/@tanstack/ai-mcp@1913

@tanstack/ai-memory

npm i https://pkg.pr.new/@tanstack/ai-memory@1913

@tanstack/ai-mistral

npm i https://pkg.pr.new/@tanstack/ai-mistral@1913

@tanstack/ai-neon

npm i https://pkg.pr.new/@tanstack/ai-neon@1913

@tanstack/ai-octane

npm i https://pkg.pr.new/@tanstack/ai-octane@1913

@tanstack/ai-ollama

npm i https://pkg.pr.new/@tanstack/ai-ollama@1913

@tanstack/ai-ollaya

npm i https://pkg.pr.new/@tanstack/ai-ollaya@1913

@tanstack/ai-openai

npm i https://pkg.pr.new/@tanstack/ai-openai@1913

@tanstack/ai-opencode

npm i https://pkg.pr.new/@tanstack/ai-opencode@1913

@tanstack/ai-openrouter

npm i https://pkg.pr.new/@tanstack/ai-openrouter@1913

@tanstack/ai-perplexity

npm i https://pkg.pr.new/@tanstack/ai-perplexity@1913

@tanstack/ai-persistence

npm i https://pkg.pr.new/@tanstack/ai-persistence@1913

@tanstack/ai-preact

npm i https://pkg.pr.new/@tanstack/ai-preact@1913

@tanstack/ai-react

npm i https://pkg.pr.new/@tanstack/ai-react@1913

@tanstack/ai-reactor

npm i https://pkg.pr.new/@tanstack/ai-reactor@1913

@tanstack/ai-remix

npm i https://pkg.pr.new/@tanstack/ai-remix@1913

@tanstack/ai-sandbox

npm i https://pkg.pr.new/@tanstack/ai-sandbox@1913

@tanstack/ai-sandbox-blaxel

npm i https://pkg.pr.new/@tanstack/ai-sandbox-blaxel@1913

@tanstack/ai-sandbox-boxd

npm i https://pkg.pr.new/@tanstack/ai-sandbox-boxd@1913

@tanstack/ai-sandbox-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-sandbox-cloudflare@1913

@tanstack/ai-sandbox-daytona

npm i https://pkg.pr.new/@tanstack/ai-sandbox-daytona@1913

@tanstack/ai-sandbox-docker

npm i https://pkg.pr.new/@tanstack/ai-sandbox-docker@1913

@tanstack/ai-sandbox-e2b

npm i https://pkg.pr.new/@tanstack/ai-sandbox-e2b@1913

@tanstack/ai-sandbox-local-process

npm i https://pkg.pr.new/@tanstack/ai-sandbox-local-process@1913

@tanstack/ai-sandbox-railway

npm i https://pkg.pr.new/@tanstack/ai-sandbox-railway@1913

@tanstack/ai-sandbox-sprites

npm i https://pkg.pr.new/@tanstack/ai-sandbox-sprites@1913

@tanstack/ai-sandbox-upstash-box

npm i https://pkg.pr.new/@tanstack/ai-sandbox-upstash-box@1913

@tanstack/ai-sandbox-vercel

npm i https://pkg.pr.new/@tanstack/ai-sandbox-vercel@1913

@tanstack/ai-skills

npm i https://pkg.pr.new/@tanstack/ai-skills@1913

@tanstack/ai-solid

npm i https://pkg.pr.new/@tanstack/ai-solid@1913

@tanstack/ai-svelte

npm i https://pkg.pr.new/@tanstack/ai-svelte@1913

@tanstack/ai-typesafe

npm i https://pkg.pr.new/@tanstack/ai-typesafe@1913

@tanstack/ai-utils

npm i https://pkg.pr.new/@tanstack/ai-utils@1913

@tanstack/ai-vercel-gateway

npm i https://pkg.pr.new/@tanstack/ai-vercel-gateway@1913

@tanstack/ai-vertex

npm i https://pkg.pr.new/@tanstack/ai-vertex@1913

@tanstack/ai-vue

npm i https://pkg.pr.new/@tanstack/ai-vue@1913

@tanstack/ai-worldlabs

npm i https://pkg.pr.new/@tanstack/ai-worldlabs@1913

@tanstack/openai-base

npm i https://pkg.pr.new/@tanstack/openai-base@1913

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@1913

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/@tanstack/react-ai-devtools@1913

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@1913

@tanstack/svelte-ai-devtools

npm i https://pkg.pr.new/@tanstack/svelte-ai-devtools@1913

commit: f1266ad

@AlemTuzlak AlemTuzlak added ai-ready Grok review bot: a maintainer can merge after they Approve secure AI review: no malware found. Waiting workflows were approved. labels Oct 27, 2026
@AlemTuzlak

Copy link
Copy Markdown
Contributor

This comment is automated by a Grok agent. It is not a maintainer review.

Verdict: ready
Head SHA: f1266ad
Label: ai-ready

Findings

  • None

Push
Did not push.

Security
clean. Added label secure. No waiting workflow runs.

Maintainers still GitHub-approve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-ready Grok review bot: a maintainer can merge after they Approve secure AI review: no malware found. Waiting workflows were approved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants