Skip to content

Evolve core contracts & extract shared primitives #3

@EmersonBraun

Description

@EmersonBraun

Parent PRD

#2

What to build

Evolve @agentskit/core to serve as the foundation for the entire v3 ecosystem. This means:

  • Upgrade ToolDefinition: enforce schema: JSONSchema7 type, add optional init()/dispose() lifecycle methods, allow execute to return AsyncIterable<unknown>, add optional tags/category for discovery
  • Add SkillDefinition: name, description, systemPrompt, optional examples, tools (tool name hints), delegates (other skill names), temperature, onActivate hook
  • Add VectorMemory: store(docs), search(query, options), delete(ids) — separate from ChatMemory
  • Add AgentEvent: Union type for lifecycle events (llm:start, llm:end, tool:start, tool:end, memory:load, agent:step, error, etc.)
  • Add Observer: { name: string, on: (event: AgentEvent) => void | Promise<void> }
  • Add EvalSuite / EvalResult: Minimal contract types for evaluation
  • Extract shared primitives: Pull executeToolCall, consumeStream, buildMessage out of ChatController into standalone exported functions so both ChatController and the future AgentRunner can use them
  • Emit AgentEvent from ChatController at appropriate lifecycle points

Core must remain zero external dependencies and under 10 KB gzipped.

Acceptance criteria

  • ToolDefinition updated with JSONSchema7 type, lifecycle methods, AsyncIterable support, discovery metadata
  • SkillDefinition interface exported from core
  • VectorMemory interface exported from core (separate from ChatMemory)
  • AgentEvent union type exported from core
  • Observer interface exported from core
  • EvalSuite and EvalResult types exported from core
  • Shared primitives (executeToolCall, consumeStream, buildMessage) exported as standalone functions
  • ChatController refactored to use shared primitives internally
  • ChatController emits AgentEvents
  • Zero external dependencies maintained
  • Bundle stays under 10 KB gzipped
  • All existing tests still pass
  • TypeScript strict mode, no any

Blocked by

None — can start immediately

User stories addressed

  • User story 4 (swap providers)
  • User story 6 (custom tools with simple contract)
  • User story 7 (JSON Schema for tool params)
  • User story 25 (observability optional)
  • User story 35 (custom memory backends with clear contract)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions