Agent systems are programs that coordinate language-model queries, tool calls, human approvals, and ordinary computation, yet existing frameworks wire them together as opaque library objects outside compiler analysis. Treating agent systems from a programming-language perspective, we present Etas, an effect-typed language that elevates agents, tools, workflows, and behavioral specifications to first-class, compiler-checked constructs. Crucially, Etas separates escaping effects from persistent effect request summaries: handlers change how an operation is interpreted without erasing its effect request from the summary, while trace specs constrain permitted effect requests and their order. The compiler composes effect request summaries across calls and handlers, discharging satisfied trace specs statically and keeping a residual monitor where dynamic paths remain uncertain. We formalize Core Etas with terminal handlers, a trace-spec monitor construction, and an abstract analysis over monitor states, proving preservation, progress, effect coverage, and trace-spec safety. We implement a compiler, an optimizer, and a checked interpreter using Rust. Across compiler fixtures and coding-agent scenarios written in Etas, Etas successfully enforces callable bounds, effect operation ordering, and handled effect request visibility with zero mismatches. The compiler also implements agent-specific optimizations that reduce execution time by 23.2%. Across 12 Etas workflows, the combined token optimization passes reduce input tokens by 67.8% on paired-correct executions. First-class agent abstractions also enable recursive self-evolution for Etas programs. Across five harness evolution iterations, task accuracy rises from 69.9% to 78.9%.
翻译:暂无翻译