The thoughtmesh-runtime is an agent executor designed to run within a Kubernetes environment. It executes agent objectives using configurable LLM models and tools.
The runtime reads its configuration from environment variables, initializes an LLM model, and executes objectives using available tools. It's designed to be orchestrated by the thoughtmesh controller as a Kubernetes Job.
The runtime reads the following environment variables on startup:
-
THOUGHTMESH_MODEL_CONFIG (JSON, required): Model configuration including provider, name, and API settings
{"provider": "openai", "name": "gpt-4", "api_key": "sk-..."} -
THOUGHTMESH_OBJECTIVE (string, required): The primary goal to achieve
"Analyze the repository and create a performance optimization report" -
THOUGHTMESH_KEY_RESULTS (JSON array, optional): Measurable outcomes to accomplish
["Identify top 5 bottlenecks", "Suggest concrete improvements", "Estimate performance gains"]
-
THOUGHTMESH_TOOLS (JSON array, optional): Available tool configurations
[{"name": "code_analyzer", "config": {...}}, {"name": "git", "config": {...}}]
Additional context may be provided via ConfigMap/Secret environment variables.
- Parse configuration from environment variables
- Initialize the specified LLM model
- Execute the objective using available tools
- Exit with code 0 on success, non-zero on failure
- Respect timeout constraints (enforced by Kubernetes Job
activeDeadlineSeconds)
- 0: Objective achieved successfully
- 1: Failed to achieve objective
The controller monitors the exit code to determine success/failure and applies retry/disposition policies accordingly.
# Build the binary
make build
# Run with example environment variables
make run-example
# Build Docker image
make docker-build
# Clean build artifacts
make clean
# Run tests
make test
# Show all available targets
make helpgo build -o thoughtmesh-runtime .export THOUGHTMESH_MODEL_CONFIG='{"provider":"openai","name":"gpt-4"}'
export THOUGHTMESH_OBJECTIVE="Your objective here"
export THOUGHTMESH_KEY_RESULTS='["Result 1","Result 2"]'
export THOUGHTMESH_TOOLS='[{"name":"tool1","config":{}}]'
./thoughtmesh-runtime.
├── main.go # Entry point
├── internal/
│ └── runtime/
│ ├── config.go # Configuration loading and validation
│ └── runtime.go # Core runtime implementation
├── Makefile # Build automation
├── Dockerfile # Container image
└── go.mod # Go module definition
- Go 1.22 or later
- Docker (for container builds)
# Format code
make fmt
# Run linter
make vet
# Run tests
make test
# Development build (no optimization)
make devThe runtime is designed to be deployed as a Kubernetes Job by the thoughtmesh controller. Example Job specification:
apiVersion: batch/v1
kind: Job
metadata:
name: thoughtmesh-agent-task
spec:
activeDeadlineSeconds: 3600
template:
spec:
containers:
- name: runtime
image: thoughtmesh-runtime:latest
env:
- name: THOUGHTMESH_MODEL_CONFIG
valueFrom:
secretKeyRef:
name: model-config
key: config
- name: THOUGHTMESH_OBJECTIVE
value: "Your objective"
- name: THOUGHTMESH_KEY_RESULTS
value: '["Result 1", "Result 2"]'
restartPolicy: Never
backoffLimit: 3See LICENSE file for details.