Skip to content

[HIGH] Documentation examples show incorrect API usage #9

@arcaela

Description

@arcaela

Problem

Multiple JSDoc examples throughout the codebase show API calls that would fail at runtime or not compile in TypeScript.

Impact

  • Severity: High
  • User Impact: Developers following examples will get errors
  • Trust: Reduces confidence in documentation accuracy

Affected Files and Issues

src/static/rule.ts

Line 197 - Calls metadata as function:
```typescript
// WRONG
when: (agent) => agent.metadata("user_type") === "customer"

// CORRECT
when: (agent) => agent.metadata.get("user_type", "") === "customer"
```

Line 225 - Calls message() as method:
```typescript
// WRONG
when: (agent) => agent.message().length > 0

// CORRECT
when: (agent) => agent.messages.length > 0
```

src/static/message.ts

Line 214 - Shows tool_id on user message:
```typescript
// WRONG - user messages can't have tool_id
const msg = new Message({ role: 'user', content: 'Hello', tool_id: optional_id });

// CORRECT
const msg = new Message({ role: 'tool', content: 'Hello', tool_id: 'required_id' });
```

Suggested Fix

Review all @example blocks and ensure:

  1. Code would actually compile with TypeScript
  2. API calls match actual method signatures
  3. Examples demonstrate valid usage patterns

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions