Skip to content

bakulev/recursive-text-agent-lab

Repository files navigation

Recursive Text Agent Lab

Minimal .NET 10 console app for running a recursive text-agent experiment on top of the OpenAI Responses API.

Project codename: Enlightment Thinking.

The repository contains two layers:

  • OpenAiProbe/: the runner application.
  • experiments/anima/: a compact public sample workspace with prompt, goal, journal, a few artifacts, and one curated generation snapshot.

What This Repository Demonstrates

The runner is intentionally narrow and file-based:

  • each generation reads a persisted workspace from disk;
  • the model can update its future prompt and goal;
  • the run produces a cumulative journal and text artifacts;
  • every generation is snapshotted as request, response, parsed decision, and summary;
  • the outer loop can stop only when the model explicitly decides continuation no longer adds signal.

This keeps the experiment reproducible without turning it into a general-purpose self-modifying runtime.

Repository Hygiene

This repository is prepared for public publication:

  • secrets are not stored in source control;
  • local build output is ignored;
  • machine-specific files are ignored;
  • the committed experiment workspace is a trimmed sample, not a full private run history.

If you run the experiment locally, configure credentials through user secrets or environment variables.

Requirements

  • .NET 10 SDK
  • Windows PowerShell or PowerShell 7
  • an OpenAI API key

Safe Secret Storage

Preferred for local development:

dotnet user-secrets set "OpenAI:ApiKey" "<your_key>" --project .\OpenAiProbe\OpenAiProbe.csproj

Optional settings:

dotnet user-secrets set "OpenAI:Model" "gpt-4.1-mini" --project .\OpenAiProbe\OpenAiProbe.csproj
dotnet user-secrets set "OpenAI:WorkspacePath" ".\experiments\local\anima" --project .\OpenAiProbe\OpenAiProbe.csproj
dotnet user-secrets set "OpenAI:DelaySeconds" "5" --project .\OpenAiProbe\OpenAiProbe.csproj

Environment variable fallback:

$env:OPENAI_API_KEY = "<your_key>"
$env:OPENAI_MODEL = "gpt-4.1-mini"
$env:OPENAI_WORKSPACE = ".\experiments\local\anima"
$env:OPENAI_DELAY_SECONDS = "5"

Run A Local Loop

.\scripts\Run-AnimaLoop.ps1

Optional parameters:

  • -Workspace .\experiments\local\anima
  • -Model gpt-4.1-mini
  • -PauseSeconds 5

The default workspace is intentionally outside the committed sample so ordinary local runs do not dirty the repository. The PowerShell loop invokes one generation at a time. The app exits with code 10 when continuation is requested; any other exit code stops the loop.

To inspect the committed public sample, read experiments/anima/. Only point the runner at that path if you intentionally want to mutate the sample.

Run The Committed Sample Explicitly

.\scripts\Run-SampleLoop.ps1

This script exists for explicit demo use. It targets experiments/anima/ on purpose and may modify tracked files in the committed sample workspace.

Direct Single-Step Run

dotnet run --project .\OpenAiProbe -- --workspace .\experiments\local\anima --steps 1

Optional arguments:

  • --model <model>
  • --workspace <path>
  • --steps <number|infinite>
  • --delay-seconds <number>

Workspace Layout

Each experiment workspace uses this structure:

  • prompt.md: mutable instruction set for future generations
  • goal.md: mutable long-horizon goal
  • journal.md: cumulative journal across generations
  • artifacts/: text artifacts created by the model
  • generations/001, generations/002, ...: raw request and response snapshots

Each generation directory stores:

  • request.json
  • response.json
  • output.txt
  • decision.json
  • summary.txt

The committed sample keeps only a single curated generation so the repository stays readable in public while still showing the full on-disk format.

For actual local experimentation, use a workspace under experiments/local/, which is ignored by git.

How A Generation Works

  1. The app reads the current prompt, goal, journal tail, artifact list, and recent summaries.
  2. It sends that state to the OpenAI Responses API together with a fixed system prompt.
  3. It expects structured JSON describing the next generation's contribution.
  4. It writes the resulting snapshots and updates the workspace.

Limits By Design

  • The agent does not execute shell commands.
  • The agent does not modify the runner source code.
  • The agent can only write inside the configured experiment workspace.
  • Generated artifact names are sanitized to safe text filenames.

Those constraints are intentional. The goal is to study continuity, iteration, and self-revision through persisted text state rather than unrestricted tool use.

License

MIT. See LICENSE.

Contributing

See CONTRIBUTING.md for local setup, change scope, and repository hygiene rules.

Security

Do not open public issues with credentials, request payloads that contain secrets, or private experiment data. See SECURITY.md.

About

Minimal .NET 10 recursive text-agent experiment using the OpenAI Responses API and a file-based persistent workspace.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors