radkit-macros
Procedural macros for the radkit agent framework.
Macros
#[skill] — Programmatic skill registration
Annotates a struct to make it a registered A2A skill. Generates an implementation of the RegisteredSkill trait that returns Arc<SkillMetadata> with the provided fields.
use skill;
use SkillHandler;
;
Register it with the agent builder:
builder
.with_skill
.build;
Required parameters
| Parameter | Description |
|---|---|
id |
Unique identifier. Used for routing and task association. |
name |
Human-readable display name. |
description |
What the skill does. Shown to the negotiator LLM. |
Optional parameters
| Parameter | Default | Description |
|---|---|---|
tags |
[] |
Keyword tags for discovery. |
examples |
[] |
Example prompts shown in the agent card. |
input_modes |
[] |
Accepted input MIME types (validated at compile time). |
output_modes |
[] |
Produced output MIME types (validated at compile time). |
MIME type validation
input_modes and output_modes are validated against a list of common MIME types at compile time. An invalid type produces a compile error with suggestions:
error: Invalid MIME type: 'text/mark'. Did you mean one of: text/markdown?
include_skill! — Compile-time AgentSkill embedding
Reads a SKILL.md file at compile time, validates its frontmatter, and returns an AgentSkillDef value ready to pass to AgentBuilder::with_skill_def.
The SKILL.md content is embedded in the binary using include_str! — no filesystem I/O happens at startup, and it works on WASM targets.
use ;
let agent = builder
.with_name
.with_skill_def
.build;
The path is relative to the crate root (CARGO_MANIFEST_DIR), the same as include_str!.
Compile errors are produced if:
- The
SKILL.mdfile does not exist at the given path - The file does not begin with
--- - The frontmatter is not closed with
---
Startup panics (not compile errors) if full validation fails (e.g. the name field has uppercase letters or the description is empty).
For a description of the SKILL.md format, see the AgentSkills specification or the Skills documentation.
#[tool] — Tool definition
Transforms an async fn into a zero-sized struct implementing BaseTool. The function name becomes the tool name visible to the LLM.
use tool;
use ;
use JsonSchema;
use Deserialize;
use json;
async
// Pass the struct, not a function call
let worker = builder
.with_tool // ← not add()
.build;
With ToolContext for state access:
async
License
MIT