Agent Skills vs. Function Calling: A Source-Level Comparison
This article examines the difference between agent skills and function calling from a source-code perspective. Using a generalized smart coding tool as a reference, it breaks down the execution pipeline of function calling, explains how skills work as prompt injectors rather than executors, and compares the two across return content, execution location, permission granularity, and responsibilities. It also covers budget-based skill discovery and outlines practical principles for designing reusable skills within a layered agent architecture.
Introduction: From Using APIs to Understanding the Implementation
Many developers understand agents only at the API documentation level: define a few tools, the model returns a call request, and the system executes it and puts the result back into the context. That level of understanding is not enough when you want to design a reusable skill system. Using the source structure of a smart coding tool (described in general terms) as a reference, this article compares skills and function calling at the code level and offers actionable design principles.
1. The Source Skeleton of Function Calling
In mainstream implementations, each tool typically implements a unified interface. Its core fields include a name, an input schema defined with a structured validation library, the actual execution function, and a permission-check function. A builder function merges default configuration with user-defined configuration, and a serialization function converts the tool into a JSON Schema that the model can recognize and sends it along with the request.
The model only sees three things: the tool name, a natural-language description, and the structured parameter schema. When the model decides to call a tool, it emits a structured call block, and the system enters a strict pipeline:
- Input schema validation;
- Custom business validation;
- Pre-call hooks;
- Permission checks;
- Actual execution;
- Result mapping;
- Post-call hooks.
The whole process is a clean request-response loop: the result is written back into the conversation history, and the model continues reasoning. Tool registration is handled by a unified assembly function that merges built-in tools with external-protocol tools, deduplicates them by name, and gives built-in tools priority.
2. What Skills Really Are: Prompt Injectors
A skill also looks like a tool on the surface, but what it returns after execution is not an execution result. Instead, it returns a newMessages field carrying a user message tagged with metadata. In other words, when the model calls a skill, what comes back is a set of instructions on what to do next, not data. A skill does not even go through the standard tool-result channel.
This leads to two direct consequences:
- Inline mode: the skill injects the “script” into the current context, and the model follows the script step by step, calling the real tools to get the work done. The skill is an orchestration layer, not an execution layer.
- Fork mode: the skill opens a child context (a fork) to run the full flow and returns only a summary of the conclusion to the main context, keeping the context budget and noise under control.
3. Key Differences at a Glance
| Dimension | Function Calling | Skills |
|---|---|---|
| Return content | Structured execution result | Instructional message |
| Execution location | Within the current pipeline | Injected into the current context or a child context |
| Uses the result channel | Yes | No |
| Main responsibility | Atomic capability | Process orchestration and knowledge injection |
| Permission granularity | Checked on every call | Checked by the tools called after injection |
4. Discovery Mechanism: Budget Control and Dynamic Visibility
Skills are not all permanently resident in the context; they are constrained by a “budget.” The system decides how many skill descriptions to inject based on the available token budget and makes them dynamically visible by relevance. This avoids the attention dilution caused by a bloated tool list and is key to stability in long sessions.
5. Practical Takeaways for Custom Skills
- Write judgments and ordering into skills, not concrete parameter values;
- Distill reusable knowledge into skills and atomic actions into tools;
- Make the Inline vs. Fork tradeoff explicit: use Fork when you need auditability and a clean context;
- Permission checks must live in the tool layer; do not make security assumptions at the skill layer;
- Keep skill descriptions budget-aware, concise, and high in signal-to-noise ratio.
6. A General Architecture Pattern
Looking at the source, mature agent architectures generally take a three-layer shape: the tool layer provides atomic capabilities, the skill layer provides orchestration and knowledge, and the model layer handles decisions. The three are decoupled through a unified message protocol, which preserves both testability and extensibility. Understanding this layering has more long-term value than memorizing any single API.
