Skip to content

Conversation

@noencke
Copy link
Contributor

@noencke noencke commented Jan 9, 2026

This adds a new language for declaring schema method signatures for use by the LLM. See the changeset for details.

In a future PR, we will remove the old way of doing it - with zod - which will allow us to remove our dependency on the zod library.

Why remove zod?

  • It reduces bundle size. We are not actually using any of the interesting runtime capabilities of zod, only the type definitions, so all that is code is being downloaded needlessly.
  • It's a semantic mismatch for our purposes. Zod is primarily designed to validate JSON on import. We are not doing that, we are just using it as a language to express TS types.
  • It doesn't have all the capabilities we need - for example, it can't model (without kludgery) types that are different on read vs. write.
  • We rely on its internal details to examine the types. Furthermore, we don't implement the full space of its types (and we don't want to).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new TypeFactory type system to the tree-agent package as an alternative to Zod for defining method and property schema signatures. The change enables future removal of the Zod dependency while maintaining backward compatibility with existing Zod-based code.

Key changes:

  • New type factory API (typeFactory.string(), typeFactory.object(), etc.) that mirrors Zod's syntax
  • Rendering infrastructure to convert TypeFactory types to TypeScript declarations for LLM consumption
  • Integration with existing method and property binding systems to support both Zod and TypeFactory types

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
packages/framework/tree-agent/src/treeAgentTypes.ts Core TypeFactory type system with interfaces, factory functions, and type guard
packages/framework/tree-agent/src/renderTfTypeScript.ts Rendering logic to convert TypeFactory types to TypeScript declaration strings
packages/framework/tree-agent/src/test/tfTypes.spec.ts Unit tests for TypeFactory type creation and type guard
packages/framework/tree-agent/src/test/tfRendering.spec.ts Tests for TypeScript rendering of TypeFactory types
packages/framework/tree-agent/src/renderSchemaTypeScript.ts Integration to dispatch between Zod and TypeFactory renderers
packages/framework/tree-agent/src/propertyBinding.ts Updated to accept both Zod and TypeFactory types for property bindings
packages/framework/tree-agent/src/methodBinding.ts Updated to accept both Zod and TypeFactory types for method signatures with new InferZod/InferTypeFactory helpers
packages/framework/tree-agent/src/index.ts Exports for new TypeFactory API and types
packages/framework/tree-agent/api-report/tree-agent.alpha.api.md API surface documentation including new types and deprecated Infer
.changeset/tree-agent-tf-types.md Comprehensive changeset with usage examples and migration guidance

@noencke noencke force-pushed the tree-agent-replace-zod branch 2 times, most recently from 4696887 to c11abe7 Compare January 12, 2026 17:58
- Renamed all TF* types to TypeFactory* (e.g., TFType -> TypeFactoryType)
- Renamed tf export to typeFactory (convention: import { typeFactory as tf })
- Renamed functions: isTFType -> isTypeFactoryType, renderTFTypeScript -> renderTypeFactoryTypeScript
- Updated changeset to reflect Type Factory naming
- All 120 tests passing
🤖 Generated with [Nori](https://nori.ai)

Co-Authored-By: Nori <[email protected]>
@noencke noencke force-pushed the tree-agent-replace-zod branch from c11abe7 to 5a9460d Compare January 12, 2026 18:02
@noencke noencke force-pushed the tree-agent-replace-zod branch from 984fbfa to f5333f9 Compare January 12, 2026 22:20
@github-actions
Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> [email protected] ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> [email protected] serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> [email protected] check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  248787 links
    1796 destination URLs
    2036 URLs ignored
       0 warnings
       0 errors


export { instanceOfsTypeFactory } from "./treeAgentTypes.js";

/**
* Converts type factory type definitions into TypeScript declaration text.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: can we document the parameters as well?

*/
export interface TypeFactoryNumber extends TypeFactoryType {
/**
* {@inheritDoc TypeFactoryType._kind}
Copy link
Contributor

Choose a reason for hiding this comment

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

Our general guidance is actually to not include @inheritDoc comments for inherited API members, despite the way they appear in the API reports. They're disruptive to intellisense :/

I REALLY wish API-Extractor took inheritance into account for this stuff 😩

"@fluidframework/tree-agent": minor
---

tree-agent: New type factory system for method and property bindings
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tree-agent: New type factory system for method and property bindings
Adds new type factory system for method and property bindings

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