Agent Skills vs. Function Calling: A Source-Code Perspective
When an AI agent invokes a "skill," what does it actually get back? Many assume a skill is just a fancier tool that returns an execution result. Looking at typical source code reveals otherwise: a skill is usually not an executor but a set of instructions injected into the model's context. This article abstracts common implementation patterns to compare agent skills with function calling, covering tool definition pipelines, inline vs. fork injection modes, skill discovery, budget control, and eight practical guidelines for designing custom skills—helping you move from "knowing how to call APIs" to truly understanding agent architecture.
What Does the Model Actually Get Back After Invoking a Skill?
A detail worth digging into in public agent source code: when the model “invokes a skill,” what does it actually receive? Many people instinctively assume a skill is just a more advanced tool that returns an execution result once called. But from a code-implementation perspective, a skill is often not a direct executor—it’s an instruction sheet telling the model “what to do next,” injected into the context. Understanding this is the key difference between “knowing how to call APIs” and “understanding agent architecture.”
This article is not tied to any specific product implementation. Instead, it starts from generic source-code patterns, abstractly breaks down the similarities and differences between the agent skill mechanism and the function-calling mechanism, and offers actionable advice for designing custom skills.
1. What Function Calling Looks Like at the Source Level
Function calling at runtime typically consists of three parts: tool definition, call parsing, and an execution pipeline.
A tool definition usually includes a name, a natural-language description, a structured input parameter schema, an execution function, and permission-check logic. At runtime, tool definitions are serialized into a structured schema recognizable by the model API and sent along with the request. The model doesn’t see source code—it sees “tool name + description + parameter structure.” When the model decides to use a tool, it outputs a structured tool-call block, which the runtime then parses and executes.
Abstract illustration:
interface ToolSpec {name: string;description: string;inputSchema: Schema;execute(args: unknown, ctx: ExecutionContext): Promise<ToolResult>;checkPermission?(ctx: ExecutionContext): boolean;}async function runToolCall(call: ToolCall, ctx: ExecutionContext) {const tool = registry.get(call.name);const args = validate(tool.inputSchema, call.args);await runBeforeHooks(tool, args, ctx);checkPermission(tool, ctx);const raw = await tool.execute(args, ctx);const result = mapToToolResult(raw);await runAfterHooks(tool, result, ctx);return result;}
This pipeline typically includes parameter validation, business validation, pre-execution hooks, permission checks, actual execution, result mapping, and post-execution hooks. Its essence is a clean request–response loop: the model initiates a tool call, the runtime executes it, the result is appended to the conversation history, and the model continues reasoning. Function calling is atomic—one call corresponds to one execution result, with relatively clear boundaries.
2. The True Nature of Skills: Prompt Injectors Wearing a Tool’s Clothing
On the surface, a skill also looks like a tool: it has a name, a description, trigger conditions, and the model “chooses” it. But the key difference lies in the return value. After a skill invocation completes, what the runtime returns is often not a business execution result, but a set of new messages—possibly a user-role message with a meta marker. In other words, after invoking a skill, the model receives an operation guide, not a “task already done” result.
Abstract illustration:
interface SkillSpec {name: string;description: string;whenToUse: string;mode: "inline" | "fork";instructions: string;allowedTools?: string[];budget?: {maxTokens?: number;maxToolCalls?: number;timeoutMs?: number;};}async function invokeSkill(skill: SkillSpec, ctx: ExecutionContext) {const rendered = renderTemplate(skill.instructions, ctx);return {injectedMessages: [{role: "user",meta: true,content: rendered}]};}
This illustrative code shows that the core action of skill execution is “render and inject instructions,” not “directly complete the business task.” Only after seeing the injected instructions does the model begin calling the real tools step by step. Skills don’t even go through the ordinary tool-result channel. What they change is the model’s subsequent behavioral strategy, not the external world directly.
This also explains why skills can be very “soft”: they can be process documentation, checklists, coding standards, step-by-step procedures, failure-handling strategies, or even constraints requiring the model to gather information before acting. A skill is a package of procedural knowledge—a workflow template, a prompt macro—rather than an atomic API.
3. Inline Mode vs. Fork Mode: Two Context Strategies
Skill injection typically comes in two modes.
Inline mode injects skill instructions directly into the current conversation context, letting the model “act it out” within the existing context. Advantages: simple to implement, context continuity preserved, well-suited for short workflows and highly interactive tasks. Disadvantages: skill instructions consume the context budget, long workflows can pollute the main conversation, and failures may leave intermediate steps in the history.
Fork mode creates a sub-execution context for the skill—effectively spawning a “clone” to do the work. The sub-context reads necessary inputs, calls tools per the skill instructions, and returns only a result summary to the main context when done. Advantages: good isolation, a clean main context, well-suited for long tasks and parallelizable tasks. Disadvantages: complex implementation—requiring handling of sub-context input/output contracts, result consistency, cost control, and observability.
Which mode to choose depends on task length, context sensitivity, failure-recovery requirements, and cost budget. Short, small-scope compliance checks fit Inline; multi-step, long-chain tasks that need isolated intermediate artifacts are better suited to Fork.
4. A Real Execution Trace for a Code-Commit Scenario
Take a “commit code” scenario: the skill does not directly perform the commit. A more reasonable trace looks like this:
- The user expresses the intent to commit; the runtime matches the “code commit skill” based on the skill description and trigger conditions.
- The runtime injects commit-workflow instructions into the context—for example, requiring it to first check the workspace status, review the diff, summarize changes, generate a commit message, and confirm risks.
- The model calls tools step by step per the instructions: read status, read diff, run checks, generate the commit message.
- The model calls the real commit tool to complete the commit.
- The runtime appends the tool result, and the model judges success or failure based on it.
- The skill workflow ends and outputs a summary to the user.
In this process, the skill handles “orchestration knowledge,” while tools handle “execution primitives.” A skill is not a replacement for git commands—it’s a process manual telling the model “what to look at before committing, in what order, and how to roll back on failure.”
5. Skill Discovery: Budget Control and Dynamic Visibility
Skills are not exposed indiscriminately. The runtime typically maintains a skill registry and decides which skills are visible based on descriptions, trigger words, current task phase, user permissions, tool availability, and budget. Dynamic visibility matters: exposing too many irrelevant skills interferes with the model’s choices and increases prompt cost and misfire risk.
Budget control is equally critical. A skill can constrain maximum token consumption, maximum tool-call count, timeout, the allowed tool set, and permission boundaries. A skill without a budget easily becomes an “infinite autonomous loop”; a skill without permission boundaries amplifies injection risk. Skill instructions themselves are context input and must be treated as untrusted content to avoid hijacking by malicious text.
6. Skills vs. Function Calling: Similarities and Differences
Similarities: both are triggered by model decisions, both depend on runtime scheduling, both are subject to permissions, validation, hooks, and observability infrastructure, and both ultimately change external state through the tool layer.
The differences can be summarized as follows:
| Dimension | Function Calling | Skill |
|---|---|---|
| Abstraction level | Atomic capability | Procedural knowledge / orchestration package |
| Executor | Runtime executes the tool function | Model continues reasoning per injected instructions and calls tools |
| Return value | Tool execution result | Injected instruction messages or subtask summary |
| Context impact | Result appended to history | Directly changes subsequent behavioral strategy |
| Atomicity | Strong | Weak; may span multiple steps |
| Composition | Combined via multiple calls | A skill can orchestrate multiple tools |
| Failure handling | Single-call failure | Can define retry, rollback, and fallback flows |
So a skill is not a simple replacement for function calling—it’s a higher-level abstraction built on top of it. Function calling answers “what can be done”; skills answer “in what order and under what constraints it should be done.”
7. What This Design Means for Writing Custom Skills
First, treat a skill as a process manual, not API documentation. Focus on clearly writing steps, checkpoints, failure branches, and output formats.
Second, split atomic tools properly. Skills orchestrate; tools execute. Don’t cram complex business logic into a single tool.
Third, define input/output contracts explicitly. A skill needs to know which context to read, which tools it may call, and what structure its final output takes.
Fourth, apply least privilege. Expose only the tools required to complete the task; add confirmation and audit for sensitive operations.
Fifth, set budgets. Limit tokens, tool-call counts, timeouts, and retries to prevent long loops.
Sixth, consider idempotency and rollback. For write operations, a skill should define recovery strategies for failures.
Seventh, be observable. Log skill triggers, injected content, tool-call chains, and final results for debugging and auditing.
Eighth, control prompt length. Skill instructions should be high-density, executable, and free of filler; excessive length crowds the context and reduces instruction-following rates.
8. The Generic Agent-Architecture Pattern Seen Through Source Code
A well-structured agent architecture typically has three layers: a tool layer providing atomic execution capabilities; a skill layer encapsulating procedural knowledge and workflow orchestration; and a runtime responsible for discovery, injection, permissions, budgets, isolation, and observation. The model acts more like an interpreter: it reads the “script” injected by the skill, then calls tools to perform the actions.
Once you understand this layering, comparing skills with function calling goes beyond the surface-level view that “both let the model invoke capabilities.” Function calling is a structured execution protocol; skills are a workflow-orchestration mechanism within the context. They are not competitors but cooperating layers: the tool layer guarantees controllable execution, while the skill layer improves the organization of complex tasks. For developers, what truly matters isn’t memorizing any specific implementation—it’s mastering this generic pattern of “primitives + orchestration + runtime governance.”
