Skip to main content

Agent SDK

The Agent SDK lets you customize and extend the RBS coding agent with project-specific capabilities. Define custom tools, system prompts, teammate roles, subagents, and slash commands — all in your WORKSPACE.rbs or BUILD.rbs files using the RBS DSL.

Overview

ExtensionAPIPurpose
Toolsnative.define_agent_tool()Custom actions the agent can take.
Promptsnative.define_agent_prompt()Specialized system prompts with linked tools.
Subagentsnative.define_agent_subagent()One-shot specialist agents for isolated tasks.
Teammate rolesnative.define_agent_teammate_role()Reusable roles for multi-agent teams.
Skillsnative.define_agent_skill()Slash commands for common workflows.

Loading built-in tools

Load the built-in agent tools (Git status, Git log, file analysis, etc.) in your workspace:

Custom tools

Basic tool with a shell command

Tool with parameters

Tool with implementation function

For complex logic, use an implementation function with full ctx access:

The ctx object for tools

When using implementation, your function receives a ctx object with these modules:

ctx.attr — Access parameters

ctx.file — File operations

ctx.dir — Directory operations

ctx.shell — Execute commands

ctx.path — Path manipulation

ctx.json — JSON operations

ctx.output — Return results

Custom prompts

Create specialized system prompts with linked tools:

Custom subagents

Create subagent types for one-shot, isolated specialist tasks:
ParameterTypeRequiredDescription
namestringYesUnique subagent name.
descriptionstringYesWhat the subagent does.
when_to_usestringNoGuidance for when to invoke this subagent.
system_promptstringYesSystem prompt for the subagent.
toolsstring listNoTools the subagent can use.
read_onlyboolNoIf True, the subagent cannot modify files.

Custom teammate roles

Create reusable roles for multi-agent teams:
ParameterTypeRequiredDescription
namestringYesRole name (used in spawn_teammate).
descriptionstringYesWhat this role specializes in.
system_promptstringYesSystem prompt for teammates with this role.
toolsstring listNoTools available to this role.
capabilitiesstring listNoDeclared capabilities for role matching.
Custom roles are automatically available when spawning teammates:

Custom skills (slash commands)

Create slash commands for common workflows:
ParameterTypeRequiredDescription
namestringYesSkill name (becomes a /command).
descriptionstringYesWhat the skill does.
usagestringNoUsage example.
promptstringYesPrompt template. Use {args} for user input.
toolsstring listNoTools the skill can use.

Long-term memory

The coding agent has a persistent memory system that remembers things across sessions — design patterns, user corrections, file-specific notes, and architectural decisions. Memory is stored as human-editable markdown in .rbs/memory/.

How memory works

Memory file format

Memory files are plain markdown, stored alongside your code:
Each entry uses ## [m-xxxxxxxx] headers:

Memory tools

ToolDescription
memory_saveSave a new memory entry.
memory_recallRecall memories for a file or package.
memory_updateUpdate an existing entry by ID.
memory_deleteDelete a stale or incorrect entry.
memory_searchSearch across all memory files.
memory_listList all stored memory files.

Editing memory directly

Memory files are just markdown. You can read, edit, add, and delete entries directly in your editor — the agent respects your changes.

Complete example

Attribute types reference

TypeDescriptionExample
attr.string()String value."hello"
attr.int()Integer value.42
attr.bool()Boolean value.True
attr.string_list()List of strings.["a", "b"]
attr.label()Build target label."//pkg:target"
attr.label_list()List of labels.["//a:x", "//b:y"]
attr.string_dict()String dictionary.{"key": "value"}
All attribute types support:
  • doc (string) — Description shown to the AI model.
  • mandatory (bool) — Whether the parameter is required.
  • default (any) — Default value.

Best practices

  1. Clear descriptions — Write descriptions that help the AI model understand when to use the tool.
  2. Document parameters — Use doc for all attributes.
  3. Handle errors — Always check for errors and return meaningful messages.
  4. Keep tools focused — Each tool should do one thing well.
  5. Define roles for your team — Create custom teammate roles matching your project needs.
  6. Use subagents for isolation — Use read-only subagents for analysis tasks.
  7. Create skills for workflows — Turn common multi-step workflows into slash commands.