Cortex for agents
Build AI agents with skills, traits, behaviors, and personas — tenant-scoped, plugin-extensible, and Forge-native.
go get github.com/xraph/cortexEverything you need for agent orchestration
Cortex handles the hard parts — personas, skills, traits, reasoning loops, and multi-tenancy — so you can focus on your application.
Agent Orchestration
Create agents with configurable reasoning loops, tool access, and persona references. Cortex handles the full lifecycle from input to intelligent action.
agent, err := eng.CreateAgent(ctx, &agent.Config{ Name: "support-agent", Model: "gpt-4o", ReasoningLoop: "react", PersonaRef: "helpful-agent", MaxSteps: 15, })"text-fd-muted-foreground/60 italic">// agent.ID = agt_01h455...Persona Composition
Compose personas from skills, traits, and behaviors to create human-emulating agents with distinct personalities and capabilities.
p, err := eng.CreatePersona(ctx, &persona.Persona{ Name: "helpful-agent", Identity: "I am a support specialist.", Skills: []persona.SkillRef{ {SkillName: "customer-support", Proficiency: "expert"}, }, })Multi-Tenant Isolation
Every agent, run, skill, and persona is scoped to a tenant via context. Cross-tenant access is structurally impossible.
ctx = cortex.WithTenant(ctx, "acme-corp")ctx = cortex.WithApp(ctx, "support-app") "text-fd-muted-foreground/60 italic">// All agents, runs, and resources are"text-fd-muted-foreground/60 italic">// automatically scoped to acme-corpPluggable Stores
Start with in-memory for development, swap to PostgreSQL for production. Every domain entity is a Go interface — 50 methods across 8 sub-interfaces.
eng, _ := engine.New( engine.WithStore(pgstore.New(bunDB)), engine.WithExtension( observability.NewMetricsExtension(), ), engine.WithLogger(slog.Default()),)Plugin Lifecycle Hooks
OnRunCompleted, OnToolFailed, and 16 other lifecycle events. Wire in metrics, audit trails, or custom logic without modifying core code.
func (e *Audit) OnRunFailed( ctx context.Context, agentID id.AgentID, runID id.AgentRunID, err error,) error { return e.record("run.failed", runID, err)}Skills & Traits System
Define skills with tool mastery levels and guidance notes. Define traits with dimensional values that influence agent tone, style, and behavior. Compose them into personas.
sk, _ := eng.CreateSkill(ctx, &skill.Skill{ Name: "customer-support", Tools: []skill.ToolRef{ {ToolName: "lookup_order", Mastery: "expert", Guidance: "Verify order ID format"}, }, DefaultProficiency: "proficient",})"text-fd-muted-foreground/60 italic">// sk.ID = skl_01h455...From input to intelligent action.
Cortex orchestrates the entire agent lifecycle — persona resolution, multi-step reasoning, tool execution, and checkpoint approvals.
Automatic Tenant Scoping
Every agent run is stamped with TenantID and AppID from context. Agent, skill, and persona isolation is enforced at the store layer — no tenant can access another's data.
Composable Persona System
Compose personas from skills (with tool mastery), traits (with dimensional values), and behaviors (with trigger-action rules). Each persona gives the agent a distinct personality.
Lifecycle Plugin Hooks
OnRunCompleted, OnToolFailed, OnBehaviorTriggered, and 16 other lifecycle events. Wire in metrics, audit trails, or custom logic without modifying engine code.
Simple API. Intelligent agents.
Create an agent and run it in under 30 lines. Cortex handles persona resolution, reasoning loops, and tool orchestration.
1package main2 3import (4 "context"5 "log/slog"6 7 "github.com/xraph/cortex/engine"8 "github.com/xraph/cortex/agent"9 pgstore "github.com/xraph/cortex/store/postgres"10)11 12func main() {13 ctx := context.Background()14 15 eng, _ := engine.New(16 engine.WithStore(pgstore.New(bunDB)),17 engine.WithLogger(slog.Default()),18 )19 20 "text-fd-muted-foreground/60 italic">// Create an agent with persona and skills21 eng.CreateAgent(ctx, &agent.Config{22 Name: "support-agent",23 Model: "gpt-4o",24 ReasoningLoop: "react",25 PersonaRef: "helpful-agent",26 InlineSkills: []string{"customer-support"},27 MaxSteps: 15,28 })29}1package main2 3import (4 "context"5 "fmt"6 7 "github.com/xraph/cortex"8 "github.com/xraph/cortex/engine"9)10 11func runAgent(12 eng *engine.Engine,13 ctx context.Context,14) {15 ctx = cortex.WithTenant(ctx, "acme-corp")16 17 "text-fd-muted-foreground/60 italic">// Run the agent synchronously18 result, _ := eng.RunAgent(ctx,19 "support-agent",20 "I want to return order #12345",21 )22 23 fmt.Println(result.Output)24 "text-fd-muted-foreground/60 italic">// "I'd be happy to help with your return..."25 fmt.Printf("Steps: %d, Tokens: %d\n",26 result.StepCount, result.TokensUsed)27}Start building with Cortex
Add human-emulating AI agents to your Go service in minutes. Cortex handles personas, skills, reasoning loops, and multi-tenant orchestration out of the box.
go get github.com/xraph/cortex