Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Task 6.1: Tool Decorator Architecture Decision #51

Description

@github-actions

Overview

Evaluate and decide on the architectural approach for implementing a tool decorator/helper system in TypeScript. This decision is critical because TypeScript's runtime limitations differ significantly from Python's runtime introspection capabilities.

Parent Task

This is a sub-task of #40 (Task 06: Create Tool Decorator System)

Work Required

1. Evaluate Approach Options

Option A: TypeScript Decorators with Manual Schema

  • Enable experimentalDecorators in tsconfig.json
  • Require developers to manually provide inputSchema as JSON Schema
  • Provide @tool() decorator syntax similar to Python
  • Document that auto-generation of schemas is not possible in TypeScript

Option B: Helper Functions (Extending FunctionTool)

  • Keep current FunctionTool pattern, add convenience wrapper
  • No experimental features needed
  • Different API from Python but more TypeScript-idiomatic
  • Still requires manual schema definition

Option C: Zod-Based Schema Definition

  • Add Zod as production dependency
  • Provide type-safe schema definition
  • Convert Zod schemas to JSON Schema at runtime
  • Better developer experience than manual JSON Schema
  • Can work with either decorators or helper functions

Option D: Build-Time Code Generation

  • Create build tool to analyze TypeScript AST
  • Extract JSDoc comments and type information at build time
  • Generate tool definitions automatically
  • Most complex but closest to Python DX

2. Key Decisions to Make

Schema Definition Strategy

  • How should developers define input schemas?
  • Manual JSON Schema vs Zod vs build-time generation?
  • Are we willing to add Zod as a dependency?

API Surface

  • Decorator syntax: @tool()
  • Helper function: tool()
  • Both?

Context Parameter Injection

  • How to identify which parameter receives ToolContext?
  • Naming convention vs explicit configuration?
  • What happens if context: false but function has context parameter?

Description/Documentation

  • Require manual description parameter?
  • Build-time JSDoc extraction?
  • Both with fallback?

Error Handling

  • Should raise_error: bool parameter bypass error catching?
  • What's the use case for propagating errors vs returning error ToolResults?

Feature Parity vs Idioms

  • Aim for Python API parity or adapt to TypeScript idioms?
  • Acceptable if DX differs from Python?

Experimental Features

  • Use experimentalDecorators: true in tsconfig?
  • Or avoid experimental features?

3. Create Proof-of-Concept (Optional but Recommended)

  • Implement small POC for top 2-3 candidates
  • Compare developer experience
  • Evaluate type safety
  • Assess maintainability

4. Document Decision

  • Create decision document explaining:
    • Chosen approach and rationale
    • Alternatives considered and why rejected
    • API contract and examples
    • Migration path from current FunctionTool (if applicable)
    • Dependencies required (if any)

5. Update Task 6.2 Description

  • Provide clear implementation requirements based on chosen approach
  • Include concrete examples of desired API
  • Specify acceptance criteria

Technical Context

TypeScript Limitations vs Python

Python has:

  • Runtime type introspection (get_type_hints())
  • Docstring parsing (docstring_parser)
  • Schema generation from types (Pydantic)
  • Function signature inspection (inspect module)

TypeScript has:

  • Type erasure (all types removed at compile time)
  • No runtime access to JSDoc comments
  • No built-in schema generation
  • Limited metadata with reflect-metadata (only basic types)

Existing Repository Patterns

  • FunctionTool class wraps callbacks with Tool interface
  • No validation libraries currently used
  • Strict TypeScript mode enabled
  • Minimal production dependencies (AWS SDK only)
  • Comprehensive test coverage required (80%+)

Exit Criteria

  • All architectural options evaluated with pros/cons
  • Decision made on approach (decorators vs helpers vs hybrid)
  • Decision made on schema definition strategy
  • Decision made on context parameter handling
  • Decision made on error handling behavior
  • Decision made on dependencies (Zod, reflect-metadata, etc.)
  • API contract defined with concrete examples
  • Decision document created explaining rationale
  • Task 6.2 (Implementation) updated with clear requirements
  • Team agreement on chosen approach

Dependencies

References

Metadata

Metadata

Assignees

Labels

project-task<agent-managed> Whether or not an agent is has managed it in the past

Type

No type

Language

None yet

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions