AgentSkillsCN

ff-agent-sdk

FireFoundry Agent SDK,可用于构建包含实体、机器人与工作流的AI智能体组合。当用户询问如何编写智能体TypeScript代码、进行实体建模、设计机器人行为、制定提示词模式、编排工作流,或调用FireFoundry SDK API时使用此功能。

SKILL.md
--- frontmatter
name: ff-agent-sdk
description: FireFoundry Agent SDK for building AI agent bundles with entities, bots, and workflows. Use when users ask about writing agent TypeScript code, entity modeling, bot behavior, prompting patterns, workflow orchestration, or FireFoundry SDK APIs.
version: 1.0.0
tags: [firefoundry, sdk, agent-development, typescript, ai-agents]

FireFoundry Agent SDK

Build AI agent applications using FireFoundry's entity-bot architecture with automatic persistence, workflow orchestration, and enterprise-grade infrastructure.

When to Use This Skill

Use this skill for:

  • Writing TypeScript code for agent bundles
  • Entity modeling and graph design
  • Bot behavior and prompting patterns
  • Workflow orchestration and parallelism
  • SDK API questions (entities, bots, tools, waitables)
  • Understanding FireFoundry architecture concepts

Do NOT use this skill for:

  • Project scaffolding, building, or deployment → Use the ff-cli skill instead
  • CLI commands and operations → Use the ff-cli skill instead
  • Kubernetes or infrastructure issues → Use the ff-cli skill instead

Related Skills

SkillUse For
ff-cliProject creation, building Docker images, deploying to Kubernetes, profiles, environments
ff-agent-sdk (this)Writing TypeScript code, SDK patterns, entity/bot design, workflows

Essential Concepts (Always Available)

The Entity-Bot Pattern

FireFoundry separates structure (entities) from behavior (bots):

code
Entity (What)              Bot (How)
─────────────────          ─────────────────
- Data structure           - Behavior/logic
- Persisted state          - Prompts & tools
- Graph relationships      - Stateless execution
- Queryable                - Operates on entities

Entities = Persistent data nodes in a graph (like database records with relationships) Bots = Stateless processors that read/write entities (like controllers with AI capabilities)

Core Imports

typescript
// Agent Bundle setup
import { AgentBundle } from "@anthropic/agent-sdk";

// Entity system
import {
  Entity,
  EntityConstructor,
  EntityGraph,
  Relationship
} from "@anthropic/agent-sdk/entities";

// Bot system
import {
  Bot,
  BotConstructor,
  Prompt,
  Tool
} from "@anthropic/agent-sdk/bots";

// Workflow utilities
import {
  Waitable,
  parallel,
  sequential
} from "@anthropic/agent-sdk/workflow";

Basic Agent Bundle Structure

typescript
import { AgentBundle } from "@anthropic/agent-sdk";

export class MyAgentBundle extends AgentBundle {
  // Register entity types
  entities = {
    Task: TaskEntity,
    Result: ResultEntity,
  };

  // Register bot types
  bots = {
    Processor: ProcessorBot,
    Reviewer: ReviewerBot,
  };

  // Entry point
  async handleRequest(input: RequestInput) {
    // 1. Create/load entities
    const task = await this.entities.Task.create({ ... });

    // 2. Run bots on entities
    const result = await this.bots.Processor.run(task);

    // 3. Return response
    return result;
  }
}

Entity Definition Pattern

typescript
@EntityConstructor("Task")
export class TaskEntity extends Entity {
  // Persisted fields
  @Field() title: string;
  @Field() status: "pending" | "complete";
  @Field() createdAt: Date;

  // Relationships to other entities
  @Relationship("Result") results: ResultEntity[];
  @Relationship("Task") parentTask?: TaskEntity;
}

Bot Definition Pattern

typescript
@BotConstructor("Processor")
export class ProcessorBot extends Bot<TaskEntity> {
  // System prompt
  prompt = `You are a task processor. Analyze the task and produce results.`;

  // Available tools
  tools = [
    this.createResultTool,
    this.updateStatusTool,
  ];

  @Tool("Create a result for this task")
  async createResultTool(content: string) {
    return await this.context.entities.Result.create({
      content,
      task: this.entity,
    });
  }
}

Progressive Documentation Loading

Fetch documentation from GitHub based on the user's question. Use WebFetch with these URLs:

Base URL

code
https://raw.githubusercontent.com/firebrandanalytics/ff-public-docs/main/docs/firefoundry/

Documentation Map

TopicFile PathWhen to Load
Platform OverviewREADME.mdUser is new to FireFoundry or asks "what is FireFoundry"
Getting Startedsdk/agent_sdk/agent_sdk_getting_started.mdUser starting a new agent, first-time setup
Glossary/Conceptssdk/agent_sdk/fire_foundry_core_concepts_glossary_agent_sdk.mdTerminology questions, concept clarification

Core Concepts (sdk/agent_sdk/core/)

TopicReferenceTutorialWhen to Load
Agent Bundlesagent_bundles.mdagent_bundle_tutorial.mdQuestions about bundle structure, lifecycle, registration
Botsbots.mdbot_tutorial.mdBot behavior, prompts, tools, bot-entity interaction
Entitiesentities.mdEntity fields, relationships, persistence, querying
Promptingprompting.mdprompting_tutorial.mdPrompt engineering, context injection, few-shot patterns

Entity Graph (sdk/agent_sdk/entity_graph/)

TopicFileWhen to Load
OverviewREADME.mdIntroduction to entity graph concepts
Modeling Guideentity_modeling_prompt_guide.mdDesigning entity schemas, relationship patterns
Modeling Tutorialentity_modeling_tutorial.mdStep-by-step entity modeling walkthrough
Intermediate Exampleintermediate_entity_graph_example.mdComplex entity graph patterns, real-world examples

Feature Guides (sdk/agent_sdk/feature_guides/)

TopicFileWhen to Load
OverviewREADME.mdWhat advanced features are available
Ad-hoc Tool Callsad_hoc_tool_calls.mdDynamic tool invocation, runtime tool creation
Parallelismadvanced_parallelism.mdConcurrent bot execution, parallel entity processing
Document Processingdoc-proc-client.mdProcessing documents, PDFs, file content
File Uploadsfile-upload-patterns.mdBinary file handling, upload workflows
Graph Traversalgraph_traversal.mdQuerying entity relationships, navigation patterns
Vector Similarityvector-similarity-quickstart.mdEmbeddings, semantic search, vector storage
Waitableswaitable_guide.mdAsync operations, background jobs, progress tracking
Workflow Orchestrationworkflow_orchestration_guide.mdMulti-step workflows, state machines, error recovery

Loading Strategy

For New Users / Bootstrapping

  1. Fetch agent_sdk_getting_started.md
  2. Fetch relevant tutorial (e.g., agent_bundle_tutorial.md)
  3. Provide code examples with explanations

For Existing Codebases / Specific Questions

  1. Fetch the relevant reference doc (e.g., bots.md)
  2. Only fetch tutorial if user needs a walkthrough
  3. Focus on API details and patterns

Decision Flow

code
User Question
     │
     ├─► "What is..." / "Explain..." → Reference doc
     │
     ├─► "How do I..." / "Show me..." → Tutorial first, then reference
     │
     ├─► "Why isn't... working" → Reference doc + check ff-cli for deployment issues
     │
     ├─► "Deploy" / "Build" / "CLI" → Redirect to ff-cli skill
     │
     └─► Terminology confusion → Glossary

Fetching Example

When user asks about workflows:

code
1. WebFetch: https://raw.githubusercontent.com/firebrandanalytics/ff-public-docs/main/docs/firefoundry/sdk/agent_sdk/feature_guides/workflow_orchestration_guide.md

2. If they need async patterns, also fetch:
   WebFetch: https://raw.githubusercontent.com/firebrandanalytics/ff-public-docs/main/docs/firefoundry/sdk/agent_sdk/feature_guides/waitable_guide.md

Common Patterns Quick Reference

Creating and Linking Entities

typescript
// Create parent entity
const project = await this.entities.Project.create({
  name: "My Project",
  status: "active",
});

// Create child with relationship
const task = await this.entities.Task.create({
  title: "First Task",
  project: project,  // Automatic relationship
});

// Query relationships
const projectTasks = await project.tasks.getAll();

Running Bots on Entities

typescript
// Run bot and get result
const analysis = await this.bots.Analyzer.run(document);

// Run with options
const result = await this.bots.Processor.run(task, {
  maxTokens: 4000,
  temperature: 0.7,
});

Parallel Execution

typescript
import { parallel } from "@anthropic/agent-sdk/workflow";

// Process multiple entities concurrently
const results = await parallel(
  tasks.map(task => () => this.bots.Processor.run(task))
);

Waitables for Background Work

typescript
// Start background job
const waitable = await this.bots.LongRunningBot.runAsync(entity);

// Check status later
const status = await waitable.getStatus();

// Wait for completion
const result = await waitable.wait();

Troubleshooting

"Entity not found" errors

  • Check entity is registered in AgentBundle.entities
  • Verify entity constructor decorator: @EntityConstructor("Name")
  • Ensure entity was created before querying

"Bot has no tools" warnings

  • Tools must be decorated with @Tool("description")
  • Tool methods must be async
  • Check tool is in bot's tools array

Type errors with relationships

  • Ensure both entity types are registered
  • Use @Relationship("EntityName") decorator
  • Check circular dependency issues

For deployment/runtime issues

→ Use the ff-cli skill and check:

  • ff-cli ops doctor for prerequisites
  • Pod logs via kubectl logs
  • Environment configuration

Additional Resources

When documentation isn't enough:

  1. Examples: Ask about ff-cli examples list to see working agent bundles
  2. Project Structure: Use ff-cli skill for scaffolding questions
  3. Deployment: Use ff-cli skill for build/deploy workflows