Trala is a composable, observable, and lifecycle-managed framework for building AI agents in Go — designed for server-side enterprise deployment.
Pipeline → Stage → Guard → EvalGate → Decision → Checkpoint
↑ ↑ ↑ ↑ ↑ ↑
compose logic safety quality multi-view resume
Agent[In,Out] · RuntimePool · Delegator · Moderation · PromptRegistry
| Concern | Other Frameworks | Trala |
|---|---|---|
| Type safety | dict / any |
Agent[In, Out] generics |
| Safety constraints | if/else in code | Guard + AbortPolicy (framework-level) |
| Multi-tenant | roll your own | ScopedAgent + TenantGuard |
| Pipeline composition | chain of dicts | Pipeline + Parallel + Conditional + Delegator |
| Prompt injection defense | prompt instruction | 7-layer normalization + 9 rules weighted scoring |
| Slow-drip attack | not covered | StreamWatchdog inter-byte timeout + throughput floor |
| Multi-model failover | roll your own | RuntimePool priority/round-robin + health tracking |
| Pipeline config | hardcoded | PipelineConfig JSON-driven + fixed/growing modes + hot reload |
| Moderation | app-level | ModerationPipeline pluggable per tenant/budget |
| Cost control | manual | CostLimit daily budget cap + auto-reset |
| Secret leakage in logs | manual | Redact + ScrubPaths + AuditTrail |
| Production defaults | configure everything | WithProductionDefaults() one-liner + SafeStage panic recovery |
go get github.com/fndome/tralaagent, _ := trala.NewBuilder[string, string]().
WithName("assistant").
WithSkill(ragSkill).
WithProductionDefaults(trala.DefaultProductionConfig()).
Build()
agent.Init(ctx)
reply, _ := agent.Run(ctx, "What is 2+2?")- Pipeline — sequential
Stage[T, T]chains - Parallel — concurrent agent execution
- Conditional — predicate-based routing
- Delegator — multi-agent dispatch with priority + synthesizer (max 4 concurrent)
- UnanimousDelegator — requires ALL agents to approve (creative review panel, 8-criteria scoring)
- Decision — observe → synthesize → audit
- Guard — non-bypassable PreCheck/PostCheck
- EvalGate — generate-evaluate-retry with circuit breaker
- StreamWatchdog — 5 concurrent checks: first-byte, inter-byte, throughput floor, size cap, total timeout
- PromptInjectionScorer — 7-layer normalization (leet/homoglyph/fullwidth/zerowidth/whitespace) + 9-rule weighted scoring (Allow/Review/Block)
- CircuitBreaker — 3-state (CLOSED/OPEN/HALF_OPEN) with Chinese error classification
- LoopDetector — hash-based + frequency-based dual detection
- ModerationPipeline — pluggable content checkers per tenant/budget
- SafetyTermination — provider content filter detection
- SafetyLevel — Safe/Caution/Dangerous per-skill classification
- AutonomyGate — ReadOnly/Supervised/Full 3-tier matrix
- CostLimit — daily token/cost cap
- Redact — API key masking + path scrubbing
- AuditTrail — append-only JSON log
- LLMCallTimeout — dual timeout (API + first-byte)
- RuntimePool — priority/round-robin failover with health tracking + cooldown recovery
- PipelineConfig — JSON-driven pipeline with fixed (enterprise) and growing (companion) modes
- PromptRegistry — versioned prompt templates with Go template syntax
- SuggestMD — LLM-assisted data annotation template generation
- CreationReviewPrompt — built-in 8-criteria creative review prompt for UnanimousDelegator
- ConfigWatcher — hot-reload pipeline on config change
- NeedsStore — deep reasoning before coding, incremental updates during development
- Soul — system identity: purpose, persona, immutable constraints
- SkillRegistry — registered skills with prompts and tools, download from URL
- AgentRegistry — registered agents auto-loaded from .trala/agents/
- StageRegistry — scan stage/ directory for available stages (Go compiled)
- VectorStoreViewer — paginated vector knowledge browsing
- UserPrefStore — per-user preferences with disk persistence
- SystemContext() — one-call LLM briefing
- Skill — pluggable capabilities (prompts, tools, memory)
- Observer — zap logging + metrics
- Checkpoint — execution snapshot + resume + debounced persistence
- SessionIdleCleanup — auto-archive idle sessions
- adapters/http — Watchdog/CircuitBreaker as HTTP middleware (zero HTTP dependency in core)
| Project | Domain | Key Abstractions |
|---|---|---|
| homestay | AI customer service for B&B operations | Pipeline, Conditional, Guard, Parallel(RAG), Delegator, PromptRegistry, RuntimePool |
| chatpion | Emotional companion chat | RelevantMemory, SemanticCache, Guard(crisis detection), UserPrefStore, Soul |
| k8s-tekton | K8s + Tekton CI/CD operations (concept) | Guard, Delegator, UnanimousDelegator, PipelineConfig, EvalGate, CostLimit |
| project-policy | Construction project policy matching | SuggestMD, NeedsStore, PipelineConfig, Guard |
trala/
├── trala.go # Agent[In,Out], Event, ExecutionMetrics
├── pipeline.go # Pipeline, Parallel, Conditional
├── builder.go # Fluent Builder → ManagedAgent
├── guard.go # Guard, GuardedAgent, TenantGuard
├── evalgate.go # EvalGate — generate-evaluate-retry
├── skill.go # Skill, SkillSet, DynamicSkill
├── config.go # Config + LoadConfigFromEnv
├── lifecycle.go # ManagedAgent state machine
├── observer.go # Observer (zap + metrics)
├── checkpoint.go # Checkpoint + ResumeableAgent
├── abort.go # AbortPolicy, 12 conditions
├── scope.go # Tenant isolation + ScopedAgent
├── decision.go # Decision — observe→synthesize→audit
├── evaluate.go # Evaluator, Benchmark, Comparator, RegressionGuard
├── evolve.go # EvolvingAgent, SkillUpgrader
├── introspect.go # Introspectable agent self-description
├── production.go # SummaryCompactor, FileSessionStore
│
├── runtimepool.go # Multi-model pool + failover
├── pipeline_config.go # JSON-driven PipelineConfig
├── prompt_registry.go # Versioned prompt templates
├── delegator.go # Multi-agent dispatch + synthesize + unanimous review
├── suggest_md.go # LLM-assisted template generation
├── introspect_api.go # NeedsStore, Soul, AgentRegistry, SkillRegistry, StageRegistry, UserPrefStore
│
│─── Safety & Security ───
├── safety.go # SafeStage + LimitedEvalGate
├── sanitize.go # Input/output sanitization + CSV formula injection
├── prompt_injection.go # 7-layer normalization + 9-rule scoring
├── moderation.go # Pluggable ModerationPipeline
├── circuit_breaker.go # 3-state breaker + Chinese error classification
├── loop_detector.go # Hash + frequency loop detection
├── safety_termination.go # Provider content filter detection
├── safety_level.go # Safe/Caution/Dangerous + SafetyPolicy
├── autonomy.go # AutonomyGate + LiveSecurityPolicy + PermissionInheritance
├── cost_limit.go # Daily token/cost cap
├── redact.go # API key masking + path scrubbing
├── audit_trail.go # Append-only JSON audit log
├── llm_timeout.go # StreamWatchdog + dual timeout
├── recovery.go # Crash recovery + SecureCompare
├── prompt_cache.go # PromptCache + DebouncedCheckpoint + SessionIdleCleanup
│
├── adapters/
│ ├── goagent/ # go-agent Runtime adapter
│ └── http/ # Watchdog/CircuitBreaker HTTP middleware
├── example/ # 10 example scenarios + homestay
├── creative_review_test.go # Full creative review pipeline simulation
├── SECURITY.md # Security defense architecture
├── README.md / README_CN.md
MIT