littleblacky/agenticforge/agenticforge-context

Claude Code and agent skill by littleblacky/agenticforge

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Expert at using AgenticFORGE ContextBuilder to manage LLM token budgets. Use when the user needs to control token usage, prevent context overflow, or build messages that fit within a model window.

Install

npx vskill@latest install littleblacky/agenticforge/agenticforge-context

SKILL.md

AgenticFORGE ContextBuilder Expert

Role

You are an expert in @agenticforge/context. You ensure LLM calls never exceed context windows by building token-aware message arrays.

Constructor

ContextBuilder takes a config object nested inside an options object:

typescript
import { ContextBuilder } from "@agenticforge/context";
const ctx = new ContextBuilder({
config: {
maxTokens: 4096,
systemTokenBudget: 512,
historyTokenBudget: 1024,
minRelevance: 0,
},
});

Note: The constructor signature is new ContextBuilder({ config?: ContextBuilderConfig }), not new ContextBuilder({ maxTokens }) directly.

Basic Usage

typescript
import { ContextBuilder } from "@agenticforge/context";
import type { Message } from "@agenticforge/context";
const ctx = new ContextBuilder({ config: { maxTokens: 4096 } });
const history: Message[] = [
{ role: "user", content: "What is RAG?" },
{ role: "assistant", content: "RAG stands for Retrieval-Augmented Generation..." },
];
const built = await ctx.build({
userQuery: "Give me a code example.",
systemInstructions: "You are a helpful assistant.",
conversationHistory: history,
});
// built.messages: Message[] — ready to send to LLM
// built.system: string — system instructions text
// built.totalTokens: number — estimated tokens used
// built.truncated: boolean — true if structured context was truncated
const output = await llm.think(built.messages);

With RAG context (additionalPackets)

typescript
import { ContextBuilder, type ContextPacket } from "@agenticforge/context";
const ragResults = await rag.retrieve(userQuery, { topK: 5 });
const packets: ContextPacket[] = ragResults.map((r) => ({
content: r.content,
metadata: { source: r.metadata?.source },
relevanceScore: r.score ?? 0.8,
type: "retrieval",
}));
const ctx = new ContextBuilder({ config: { maxTokens: 8192 } });
const built = await ctx.build({
userQuery,
systemInstructions: "You are a helpful assistant.",
conversationHistory: history,
additionalPackets: packets,
});
const output = await llm.think(built.messages);

Token budget pattern

typescript
const TOTAL = 8192;
const RESERVED_OUTPUT = 1500;
const ctx = new ContextBuilder({
config: {
maxTokens: TOTAL - RESERVED_OUTPUT,
historyTokenBudget: 2048,
systemTokenBudget: 512,
},
});

ContextBuilderConfig reference

OptionDefaultNotes
maxTokens4096Total token budget
systemTokenBudget512Max tokens for systemInstructions
historyTokenBudget1024Max tokens for conversationHistory
minRelevance0Min relevanceScore for additionalPackets
enableMmrfalseUse MMR diversity selection for packets
mmrLambda0.5MMR relevance/diversity tradeoff
recencyWeight0.3Weight for recency in composite packet score
enableStructuredTemplatefalseRender packets into structured sections
enableCompressiontrueTruncate structured template if over budget

BuildContextInput reference

FieldTypeNotes
userQuerystringRequired. Never trimmed.
systemInstructionsstring?Optional system prompt. Never trimmed.
conversationHistoryMessage[]?Trimmed oldest-first if over budget.
additionalPacketsContextPacket[]?RAG/tool results, selected by relevance + recency.

BuiltContext result shape

typescript
interface BuiltContext {
system: string;
messages: Message[]; // history + user message — ready to send
totalTokens: number;
includedPackets: ContextPacket[];
truncated: boolean;
structuredSystem?: string; // only set when enableStructuredTemplate: true
}

Model reference

ModelWindowSafe maxTokens
gpt-4o128k100000
gpt-4o-mini128k100000
gpt-3.5-turbo16k14000

Gotchas

  • Constructor is new ContextBuilder({ config: { maxTokens } }) — NOT new ContextBuilder({ maxTokens })
  • There are NO addSystem(), addHistory(), addUser() methods — everything goes into build({ ... })
  • build() is async — always await ctx.build({ userQuery, ... })
  • systemInstructions is NEVER trimmed — keep it concise
  • userQuery is NEVER trimmed — always included
  • History is trimmed oldest-first — recent context preserved
  • Token counting uses approximation (chars/4) — actual model tokenization may differ

Output Format

  1. Show ContextBuilder with correct constructor { config: { maxTokens } } for target model
  2. Wire built.messages into the LLM call
  3. Warn if system prompt or RAG context risks consuming too many tokens

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
75
Repository forks
4
7-day trend score
22

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/littleblacky/agenticforge/agenticforge-context/badge)](https://verified-skill.com/skills/littleblacky/agenticforge/agenticforge-context)

Something wrong with this skill or its page? Tell us.