Agent Skills Source Code Implementation vs. Function Calling: Key Differences
This article examines how Agent Skills are implemented at the source code level and how they differ from Function Calling. It breaks down the standard Function Calling pipeline, explains why Skills return workflow instructions instead of execution results, and compares Inline and Fork execution modes. Readers will also find practical guidance on Skill discovery, budget control, and designing custom Skills for production Agent architectures.
Agent Skills Source Code Implementation vs. Function Calling: Key Differences
1. Why We Need to Go Back to the Source Code
As intelligent coding tools and general-purpose Agent frameworks evolve rapidly, many developers still understand “tool calling” only at the API documentation level: the model outputs a structured call intent, the runtime executes it, and the result is written back. Once “reusable capability packages” such as Skills appeared, documentation alone can no longer explain a critical phenomenon: after calling a Skill, the model often receives not an execution result, but a set of instructions for what to do next.
Using a source code leak from an intelligent coding tool as the starting context (without involving any specific product or brand), this article abstracts the implementation pattern, explains how Skills are realized at the code level, and compares them layer by layer with Function Calling. The goal is to move the understanding from “being able to call an API” to “being able to design an execution pipeline.”
2. The Standard Form of Function Calling in Source Code
1. Tool Abstraction Interface
In a mature Agent runtime, each tool usually implements a unified interface. Its core fields include: name, a structured Schema for input parameters (often defined with declarative validation libraries such as Zod), an execution function, and a permission check function. Tools are created through a builder function that merges default configuration with custom configuration, then serialized into a JSON Schema that the model side can recognize.
2. What the Model Actually Sees
The model sees only three things: the tool name, a natural language description, and the parameter Schema. It is unaware of execution details and is only responsible for outputting a structured tool call block when needed.
3. Strict Execution Pipeline
Once the runtime receives the call block, it enters a fixed pipeline, typically with seven steps:
- 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 model requests, the system executes, the result is written back into history, and the model continues reasoning.
4. An Easily Overlooked Detail
When tool results are written back, they usually carry a “source marker” used to distinguish real user input from system-injected content. This marker may look simple, but it is the infrastructure that makes the later Skill design possible.
3. The Real Nature of Skills: Prompt Injectors in Tool Clothing
1. Key Source Code Signal
In one implementation, around line 580, you can see that after a Skill finishes executing, the returned structure contains a message array field, into which a user message marked with “meta information” is inserted. In other words, what the model gets after calling a Skill is not an “execution result,” but an instruction sheet for “what to do next.” Only after reading the instructions does the model start calling the real tools one by one to complete the task.
2. Essential Differences from Function Calling
- Function Calling: calling means execution, and the result is data.
- Skills: calling means injection, and the result is workflow instructions.
- Skills do not even go through the standard tool result channel. Instead, they reuse the conversation history channel and enter the context as “pseudo-user messages.”
This means Skills are not “more powerful tools,” but “programmable context orchestrators.”
4. Two Execution Modes of Skills
1. Inline Mode: Inject the Script and Let the Model Perform It
Inline mode injects the Skill content directly into the current context, and the model follows the script step by step to call tools within the same session. The advantage is continuous context, interactivity, and the ability to make corrections midway. The disadvantage is that it consumes the main context budget, and long workflows can easily squeeze the effective window.
2. Fork Mode: Send a Clone to Work and Bring Back Only the Result
Fork mode opens an independent sub-context (a clone) for the Skill. Multiple tool calls are completed inside the sub-context, and the main context receives only the final summary or structured result. The advantage is that the main context stays clean, making it suitable for long-running and batch tasks. The disadvantage is that the intermediate process is invisible and debugging costs are higher.
3. Selection Guidance
- Strong interaction and process control are needed: choose Inline.
- Long chains, parallelism, and result orientation are needed: choose Fork.
- Production systems are advised to support both modes, with the orchestration layer routing by task type.
5. The Real Execution Trace of a Commit Action (Abstract Example)
Taking a “commit code” type Skill as an example, its typical trace is:
- The model initiates a Skill call;
- The runtime injects the instruction sheet (meta message);
- The model follows the instructions and calls tools in sequence: view changes, check conventions, run tests, and generate a description;
- Each sub-tool still goes through the standard seven-step pipeline;
- After everything is complete, the Skill returns a structured summary;
- The main context continues or ends.
Illustrative pseudocode:
// Core structure returned by Skill execution (abstract representation)return {newMessages: [{role: "user",isMeta: true,content: "Please execute according to the following script: 1) view changes 2) validate conventions 3) run tests 4) output a summary"}]};
6. Skill Discovery Mechanism: Budget Control and Dynamic Visibility
Skills are not all permanently visible to the model; they are dynamically visible under “budget” constraints:
- Only the names and short descriptions of Skills are injected into the system prompt to control initial context cost;
- The model loads full instructions on demand, avoiding injecting all scripts at once;
- Dynamic visibility allows the number of capabilities to scale without linearly increasing context usage.
This is a typical engineering technique of “separating capability discovery from capability loading” in Agent architecture.
7. Implications for Writing Custom Skills
- The essence of a Skill is prompt engineering and workflow orchestration, not a traditional function library;
- Instruction sheets should be executable, verifiable, and rollback-capable, avoiding vague natural language;
- Clearly choose Inline or Fork, and declare input and output contracts;
- Move permissions and validation to the front, and reuse the underlying tool pipeline rather than bypassing it;
- Control description length to optimize the probability and accuracy of being discovered;
- Design breakpoints and summary mechanisms for long tasks to reduce context pressure.
8. General Patterns of Agent Architecture Seen from Source Code
A general paradigm can be abstracted:
- Tool layer: atomic capabilities with a strict pipeline;
- Skill layer: workflow orchestration with injection-based instructions;
- Orchestration layer: mode routing, budget control, and dynamic discovery;
- Context layer: meta markers distinguish sources to ensure security and traceability.
This layering is consistent with the capability layering approach emphasized in Baidu AI Cloud’s engineering practices related to Agents: standardized atomic tools, pluggable workflow orchestration, and controllable context governance.
9. Conclusion
Skills and Function Calling are not a replacement relationship, but different abstraction layers: the former solves “how to organize the workflow of doing things,” while the latter solves “how to do one thing safely.” Only by understanding the injection points, execution pipelines, and budget mechanisms in the source code can you make the right trade-offs in custom Skill and Agent architecture design, moving the system from “demo-ready” to “production-ready.”
