Skip to content

thoughtmesh/thoughtmesh-runtime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

thoughtmesh-runtime

The thoughtmesh-runtime is an agent executor designed to run within a Kubernetes environment. It executes agent objectives using configurable LLM models and tools.

Overview

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.

Configuration (Environment Variables)

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.

Runtime Behavior

  1. Parse configuration from environment variables
  2. Initialize the specified LLM model
  3. Execute the objective using available tools
  4. Exit with code 0 on success, non-zero on failure
  5. Respect timeout constraints (enforced by Kubernetes Job activeDeadlineSeconds)

Exit Codes

  • 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.

Building and Running

Using Make

# 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 help

Manual Build

go build -o thoughtmesh-runtime .

Running Manually

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

Project Structure

.
├── 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

Development

Prerequisites

  • Go 1.22 or later
  • Docker (for container builds)

Development Workflow

# Format code
make fmt

# Run linter
make vet

# Run tests
make test

# Development build (no optimization)
make dev

Kubernetes Deployment

The 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: 3

License

See LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors