fieldstate-agent v0.1.0

FieldState

80% fewer tokens for multi-step AI agents. Same quality. Real-time objective diagnostics.

Standard AI agents re-read their full conversation history at every step — input token cost grows linearly, forever. FieldState replaces history with a compact geometric field state that stays flat regardless of task length.

Input tokens per step — 12-step code review task (measured)
Step 1
191
210
≈ same
Step 4
2,272
810
−64%
Step 8
4,914
617
−87%
Step 12
5,823
346
−94%

Installation

pip install fieldstate-agent

For the web UI (local comparison tool):

pip install "fieldstate-agent[web]"

Requires Python 3.11+ and an Anthropic API key.

Quick Start

from fieldstate import FieldAgent

agent = FieldAgent(
    task="Review this codebase and suggest improvements",
    objectives=["thoroughness", "efficiency", "clarity"],
    api_key="sk-ant-..."  # or set ANTHROPIC_API_KEY
)

# Step 1
output, signal = agent.step("What are the security issues in auth.py?")
print(output)

# Step 2 — token cost stays flat, signal updates
output, signal = agent.step("How severe is the SQL injection risk?")

# Field signals — invisible to standard agents
if signal.suppressed:
    print(f"⚠ {signal.suppressed} is being suppressed")

print(f"Token saving: {agent.token_savings_pct:.0f}%")

FieldAgent

The main class. Wraps the Anthropic API with a field state engine. History is truncated to the last exchange; a compact field state replaces it.

from fieldstate import FieldAgent

agent = FieldAgent(
    task="Your task description",          # what the agent is doing
    objectives=["obj1", "obj2", "obj3"],  # 2–4 objectives
    api_key="sk-ant-...",                  # or ANTHROPIC_API_KEY env var
    model="claude-haiku-4-5-20251001",      # default
    max_tokens=600,                          # default
)

output, signal = agent.step("your message")

# Token tracking
agent.tokens_used          # total tokens used (input + output)
agent.input_tokens_used    # input tokens only
agent.token_savings_pct    # estimated % saved vs standard agent
agent.step_count           # number of steps run
agent.field_state          # current FieldSignal
agent.summary()            # formatted summary string

Drop-in Adapter

Already using the Anthropic SDK? Change one line.

# Before
import anthropic
client = anthropic.Anthropic(api_key="sk-ant-...")

# After — one line change
from fieldstate.adapters import FieldStateClient
client = FieldStateClient(
    api_key="sk-ant-...",
    task="Your agent's task",
    objectives=["accuracy", "speed", "clarity"],
)

# Identical API — no other changes
response = client.messages.create(
    model="claude-haiku-4-5-20251001",
    max_tokens=600,
    messages=[{"role": "user", "content": "Your message"}]
)

print(response.content[0].text)
print(f"Saving: {client.token_savings_pct:.0f}%")
print(f"Signal: {client.last_signal}")

Compare Helper

Run the same task through both agents and get a comparison dict.

from fieldstate import compare

results = compare(
    task="Plan a product launch",
    objectives=["user_value", "feasibility", "revenue"],
    steps=[
        "What are the top 3 pain points?",
        "Which feature should we build first?",
        "CEO says revenue matters more now. Does that change things?",
        "Summarize in 3 bullet points.",
    ],
    verbose=True  # prints live progress
)

print(results["token_saving_pct"])      # e.g. 67.3
print(results["signals_fired"])         # how many field signals
print(results["standard_input_tokens"])  # baseline
print(results["field_input_tokens"])     # FieldState

Web UI

Run a local comparison tool — type anything, both agents respond side by side.

# Install with web extras
pip install "fieldstate-agent[web]"

# Start the server
fieldstate serve

# Or from Python
from fieldstate.web.server import serve
serve(port=8000)

Or try the hosted demo →

Field Signals

After each step, FieldState returns a FieldSignal with real-time diagnostics about your agent's objective dynamics. Standard agents have no equivalent.

conflict
Objectives are pulling in genuinely different directions. The agent is making incompatible trade-offs.
⚠️
suppressed
One objective is being systematically ignored across multiple steps. Balance is breaking.
📉
drift
The agent is losing balance — consistently favouring one objective while another withdraws.
⚖️
deadlock
Genuine impasse — no objective is resolving. Human input recommended.
output, signal = agent.step("your message")

signal.conflict          # bool
signal.suppressed        # str | None — which objective
signal.drift             # bool
signal.drift_toward      # str | None — which objective is dominating
signal.deadlock          # bool
signal.basins            # dict — {objective: "decisive"|"synthesis"|"avoidance"|"collapse"}
signal.irrevs            # dict — {objective: 0.0–1.0 irreversibility}
signal.inertia           # float — overall field commitment (0–1)
signal.description       # str — plain English summary

How It Works

FieldState maintains one 64-dimensional state vector per objective (called a Mindlet). After each agent step:

01

Decision scoring

The agent's output is scored per-objective (0–1) reflecting how much each objective was favoured or suppressed.

02

Field update

Each Mindlet's state is updated using a directional perturbation toward decisive, synthesis, or avoidance — based on the score. Zero API cost. Pure Python math.

03

Signal detection

Basin positions and irreversibility scores are computed. Conflict, suppression, drift, and deadlock are detected from the field geometry.

04

Field injection

~30 tokens of field state replace thousands of tokens of conversation history in the next API call. Per-step cost stays flat.

Benchmarks

All measurements use claude-haiku-4-5-20251001, token counts from response.usage. Two independent runs confirmed.

StepsStandard (tokens)FieldState (tokens)Saving
611,5403,40870%
1242,4876,82184%
20~111,000~11,00090%
50~670,000~28,00096%

Quality evaluation (LLM-as-judge, thoroughness + clarity): 5/5 on both agents across two task types.

Adversarial testing: FieldState was stress-tested against specific recall, contradiction detection, and cumulative constraint tracking. The hybrid field + fact register architecture passes 2/3 adversarial scenarios. The remaining edge case (explicit contradiction vocabulary) is documented in the GitHub repo.

API Reference

FieldAgent

ParameterTypeDefaultDescription
taskstrrequiredWhat the agent is working on
objectiveslist[str]required2–4 objectives to track
api_keystrenv varAnthropic API key
modelstrhaiku-4-5Any Anthropic model
max_tokensint600Max output tokens per step

FieldSignal properties

PropertyTypeDescription
conflictboolObjectives in different basins
suppressedstr | NoneObjective being ignored
driftboolAgent losing balance
drift_towardstr | NoneDominating objective
deadlockboolNo objective resolving
basinsdict{obj: basin_name}
irrevsdict{obj: 0.0–1.0}
inertiafloatOverall field commitment

Limitations

Be aware of these before using in production:

FieldState v0.1.0 · MIT License · Live demo · GitHub