CogForge: Java Agent Framework
A Java-based tool-using agent framework built on Spring AI with MCP-compatible tool protocol, ReAct execution loops, and observable event streams.
Overview
CogForge is a purpose-built Java SDK for building autonomous tool-using agents. Rather than relying on Python-centric frameworks, it brings first-class agent capabilities to the Spring ecosystem using Java 21 features: sealed interfaces for agent types and events, records for immutable data, and reactive Mono/Flux chains throughout.
The core abstraction is the ReAct loop: an agent reasons about a goal, selects and calls tools, observes results, and iterates until the task is complete or constraints are hit. Every action emits typed AgentEvent objects via a Flux stream, making the entire execution observable and auditable.
Tech Stack
Deep Dive
Tools follow the MCP (Model Context Protocol) standard — each tool has a JSON Schema, safety annotations (readOnly, destructive, idempotent), and a reactive execute method. Built-in tools include sandboxed shell execution, file operations, and HTTP requests. A SpringAiToolAdapter bridges CogForge tools to Spring AI's ToolCallback interface so the LLM sees proper tool schemas.
Designed to integrate with Cog-Bot's cognitive memory spaces for agent learning — agents can store reflections and query accumulated heuristics across runs.
Key Outcomes
- Sealed interface type system for Agent, AgentEvent, and Tool abstractions
- ReAct (Reason + Act + Observe) execution loop with configurable constraints
- MCP-compatible tool protocol interoperable with Claude, Spring AI, and other MCP clients
- Observable event stream: every tool call, thought, and reflection emitted as typed events
- MockChatModel test harness for deterministic agent testing without LLM calls
- Built-in sandboxed tools: shell execution, file read, HTTP request
- Spring Boot auto-configuration with @ConfigurationProperties