Procedure Scope
Procedures can be scoped to a single agent (private) or shared across all agents in a tenant (shared). Scope determines which agents can match and execute a procedure during reasoning.
Scope Levels
| Scope | AgentId | IsShared | Visible To |
|---|---|---|---|
| Agent-Private | Specific agent ID | false | Only the owning agent |
| Tenant-Shared | null | true | All agents in the tenant |
When to Use Shared Procedures
Use shared (tenant-level) procedures for tasks that multiple domain agents might need to perform:
- User identity lookup — any agent might need to look up a user by name
- Standard greeting and sign-off patterns
- Escalation to human procedures — consistent across all agents
- Company-wide compliance checks — must be consistent regardless of agent domain
Setting Scope in agents-app
// When creating a procedure via API:
POST /api/octopus/procedures
{
"name": "user_identity_lookup",
"description": "Look up a user by name or email",
"triggerPattern": "look up user|find employee|who is",
"agentId": null, // null = shared
"isShared": true,
"steps": [...]
}
// Agent-private procedure:
{
"name": "vendor_onboarding",
"agentId": "5e7d3a1b-...", // specific agent
"isShared": false,
"steps": [...]
}
Precedence Rule
When both an agent-private and a tenant-shared procedure match the same trigger pattern, the agent-private procedure takes precedence. This allows agents to override shared procedures with domain-specific behavior:
// FindMatchAsync precedence:
var agentMatch = procedures.FirstOrDefault(
p => p.AgentId == agentId && p.IsApproved && Regex.IsMatch(task, p.TriggerPattern));
if (agentMatch != null) return agentMatch; // agent-private wins
var sharedMatch = procedures.FirstOrDefault(
p => p.IsShared && p.IsApproved && Regex.IsMatch(task, p.TriggerPattern));
return sharedMatch; // fallback to shared
Editing a tenant-shared procedure immediately affects all agents that use it. Test changes carefully using the trigger pattern tester before saving. Consider creating an agent-private override for one agent first to validate the new behavior before applying it tenant-wide.