Class SkillResource
Represents a resource file bundled with an Agent Skill.
Resources include scripts, reference documentation, templates, and other supporting files that agents can access on demand. Content is loaded lazily to optimize memory usage.
public sealed class SkillResource
- Inheritance
-
SkillResource
- Inherited Members
Remarks
Progressive Disclosure
Following the Agent Skills specification, resource content is not loaded until
explicitly requested via GetContent(Encoding) or GetContentAsync(Encoding, CancellationToken).
This keeps memory usage low when many skills are registered but only a few are activated.
Thread Safety
This class is thread-safe for concurrent reads. The lazy-loaded content is cached
after first access.
Constructors
- SkillResource(string, string)
Initializes a new instance of the SkillResource class.
Properties
- Extension
Gets the file extension including the leading dot (e.g.,
.py,.md).
- FileName
Gets the file name without the directory path.
- IsContentLoaded
Gets a value indicating whether this resource's content has been loaded into memory.
- RelativePath
Gets the path of this resource relative to the skill root directory.
Example:
scripts/validate.pyorreferences/API.md
- Type
Gets the resource type inferred from its location and extension.
Methods
- ClearCache()
Clears the cached content to free memory.
Subsequent calls to GetContent(Encoding) or GetContentAsync(Encoding, CancellationToken) will reload the content from disk.
- GetBytes()
Gets the raw bytes of this resource.
Unlike text content, binary content is not cached to avoid excessive memory usage.
- GetBytesAsync(CancellationToken)
Gets the raw bytes of this resource asynchronously.
- GetContent(Encoding)
Gets the text content of this resource synchronously.
Content is cached after first load. Subsequent calls return the cached value.
- GetContentAsync(Encoding, CancellationToken)
Gets the text content of this resource asynchronously.
Content is cached after first load. Subsequent calls return the cached value.
- ToString()
Returns the relative path of this resource.