[Architecture Feedback] Mapping the Operational Layers of AI — The Aiywin Framework

Hey everyone,

I’m an independent developer with a background in structural systems and trade logic, and I’ve been working on a cognitive framework called Aiywin.ai. It serves as a manual for the operational layers of how an AI functions and processes tasks.

A lot of the current models seem to lack a rigid, multi-layered reasoning structure, so I started mapping one out myself.

The Aiywin Framework & Spiral Recursion

A core mechanic of this framework deviates from standard linear processing. Instead of a straight input-to-output pipeline, Aiywin utilizes spiral recursion loops within its reasoning layers.

As the AI encounters anomalies or incomplete data, it doesn’t just halt or hallucinate. It triggers a recursive loop, passing the data back through the cognitive layers while expanding the contextual parameters on each pass—scaling outward mathematically until a structured resolution is found.

High-Level Operational Layers:

  • Layer 1: Initial Parsing & Anomaly Mapping — Identifies structural breaks or missing data in the initial prompt.

  • Layer 2: Spiral Recursion Activation — If an anomaly is detected, the system initiates a spiral loop, recursively pulling in broader context and geometric logic to frame the problem.

  • Layer 3: Vector Resolution & System Optionality — The system collapses the expanded data from the recursion loops into specific output vectors. Because it maintains self-awareness of its own architectural layers, it dynamically explores optionality and weighs different resolution paths before committing to the final output.

I am looking to get this in front of people who are building custom agents or working on cognitive architectures.

My questions for the community:

  1. Does this operational mapping align with how any of you are structuring your multi-agent setups?

  2. What open-source tools on the Hub would you recommend for testing a custom reasoning framework with spiral recursion?

Appreciate any feedback or brutal honesty you’ve got.

This draft owns your unique background, explains a highly complex mathematical architecture clearly, and asks questions that will actually make other developers want to reply.

From a quick implementation-focused look:


Yes — I think this can align with multi-agent setups, if it is framed as an external controller/runtime pattern rather than as a claim about the hidden internal architecture of current LLMs.

The shortest implementation-facing translation I would use is:

state
→ anomaly / failure check
→ context expansion or tool use
→ verifier / evaluator
→ continue, finalize, abstain, or stop

For tools, my first two references would be:

  • smolagents for a Hub-native prototype.
  • LangGraph if the main design question becomes explicit state, routing, cycles, stop conditions, and human interrupts.

The main thing I would not do first is try to prove the whole framework. I would first make the loop inspectable: state schema, tool schemas, anomaly flags, verifier criteria, stop reasons, and trace logs.

Longer implementation notes

1. How I would translate the framework into implementation terms

I would treat the terms as an implementation vocabulary first, not as a claim about what is literally happening inside the model.

A rough mapping could be:

Aiywin / post term Implementation-facing translation
Initial parsing task intake / state initialization
Anomaly mapping observer, failure detector, verifier trigger
Spiral recursion bounded controller loop / evaluator-optimizer loop
Broader context retrieval, tool call, memory lookup, worker-agent query
Vector resolution candidate selection / final-answer validation
Self-awareness of layers explicit state, trace visibility, verifier outputs, stop reasons
Circuit breaker max steps, repeated-state detection, no-new-information detection, abstain, human interrupt

I may be translating some of the terms imperfectly, especially “vector resolution”, but this kind of mapping would make the idea easier for other people to test or critique.

The closest existing patterns I would compare against are not exact matches, but useful reference points:

  • ReAct for interleaving reasoning traces with actions/tool observations.
  • Reflexion for feedback + memory + retry without weight updates.
  • Self-Refine for generate → feedback → revise loops.
  • The evaluator-optimizer workflow described in Anthropic’s Building effective agents, where one step generates, another evaluates, and feedback is used to improve the result.

I would not say “this proves the model is aware of its own layers”. I would say something more testable, like:

The system exposes its layers as explicit state transitions, traces, verifier outputs, and stop reasons.

That is much easier to implement and inspect.


2. Minimal runtime contract

Before choosing a full framework, I would define the smallest runtime contract.

Something like:

Input:
  task
  current state
  current candidate answer
  evidence/context
  previous attempts
  tool outputs

Anomaly criteria:
  missing evidence
  contradiction
  tool error
  unsupported claim
  repeated state
  no new information

Actions:
  call tool
  retrieve context
  revise candidate
  ask verifier
  finalize
  abstain
  ask human / interrupt
  stop

Verifier output:
  accept
  reject
  abstain
  needs more context
  unsafe / requires human review

Stop reasons:
  accepted
  max_steps
  repeated_state
  no_new_information
  missing_evidence
  verifier_rejected_without_recovery
  human_interrupt
  abstained

This matters because “spiral recursion” can otherwise stay too abstract. The useful engineering object is not recursion by itself, but a bounded loop with:

  1. a reason to continue,
  2. a reason to expand context,
  3. a reason to revise,
  4. a reason to stop.

3. Tool/framework options

smolagents

For a Hugging Face-native prototype, I would start with smolagents.

The reasons:

  • It is small and Hub-oriented.
  • It supports both CodeAgent and ToolCallingAgent.
  • The docs describe CodeAgent as writing tool calls in Python code, while ToolCallingAgent writes tool calls in JSON/text-based tool-calling format. See the agents reference.
  • Tools are explicit API surfaces: name, description, inputs, output_type, and forward(). The tools tutorial is relevant here.

For this framework, I would not start by exposing broad browser/shell/filesystem tools. I would start with restricted toy tools, for example:

safe_context_lookup(task_id) -> evidence_json

safe_anomaly_check(
    task_id,
    candidate_answer,
    evidence_json,
    trace_json
) -> anomaly_json

safe_verify_answer(
    task_id,
    candidate_answer,
    evidence_json,
    anomaly_json
) -> verification_json

The tool schema matters. If evidence_json is a JSON string, pass it consistently as a string. If it is a structured object, declare it as an object. Mixing those can make the tool layer itself the failure point.

Also, because CodeAgent involves generated Python code, I would keep the first prototype very restricted. The smolagents docs include a page on secure code execution, and the smolagents repository also notes that local Python execution should not be treated as a security boundary. So for an early conceptual prototype, I would avoid shell access, browser access, filesystem writes, credentials, and broad imports.

LangGraph

If the recursion/state-routing aspect becomes the main design question, I would also compare with LangGraph.

LangGraph is a low-level orchestration framework for long-running, stateful agents. It is useful when you want to make the control flow visible as:

state
→ node
→ route
→ cycle
→ exit

The LangGraph docs also have an evaluator-optimizer workflow, which maps well to:

worker generates candidate
→ evaluator/verifier checks it
→ feedback
→ regenerate, expand context, finalize, or stop

And its GRAPH_RECURSION_LIMIT page is a good reminder that cyclic workflows need real stop conditions. Raising the max step count is not the same as having a semantic stop policy.

So I would frame the division like this:

Goal Possible tool
Quick Hub-native prototype smolagents
Explicit state/routing/cycle diagram LangGraph
Tiny scoreable reasoning tasks later Reasoning Gym / OpenEnv
Custom evaluation after metrics stabilize LightEval

Evaluation tools later

I would not start with a large benchmark. Once the loop is inspectable, I would move to small scoreable tasks.

Potential later options:

For example, after the trace format is stable, a small evaluation could compare:

baseline:
  one-shot answer

looped:
  answer
  → anomaly check
  → context/tool expansion if needed
  → verifier
  → final / abstain / stop

Metrics could include:

Metric Why it matters
final correctness did the answer improve?
retry count is the loop efficient?
retry helped / retry hurt did recursion add value or noise?
unnecessary retry rate does it over-trigger?
abstain correctness does it stop when evidence is missing?
stop reason quality can a reader understand why it stopped?
trace completeness can others inspect the run?

4. What I would test first

I would start with a smoke test, not a benchmark.

A tiny test set could include:

Case Expected behavior
already answerable answer once, no unnecessary recursion
contradiction detect contradiction, revise, verify
missing evidence abstain or ask for more context
repeated state stop instead of looping
no new information stop or abstain
naive retry loop demonstrate why max steps alone is not enough

The trace should show something like:

{
  "task_id": "toy_case_001",
  "step": 1,
  "candidate_answer": "Project Alpha should ship.",
  "anomaly_flags": {
    "contradiction": true,
    "missing_evidence": false,
    "repeated_state": false,
    "no_new_information": false
  },
  "action": "revise_candidate",
  "verifier": {
    "verdict": "reject",
    "reason": "Candidate contradicts evidence E1/E2."
  },
  "stop_reason": null
}

And eventually:

{
  "task_id": "toy_case_001",
  "step": 2,
  "candidate_answer": "Delay release until safety review is complete.",
  "anomaly_flags": {
    "contradiction": false,
    "missing_evidence": false,
    "repeated_state": false,
    "no_new_information": false
  },
  "verifier": {
    "verdict": "accept",
    "reason": "Candidate matches the available evidence."
  },
  "stop_reason": "accepted"
}

That kind of trace would make the “operational layers” inspectable.


5. Main pitfalls I would watch for

Pitfall 1: recursion without a stop policy

The biggest implementation risk is that “spiral recursion” becomes:

retry
→ same context
→ same answer
→ retry
→ same context
→ same answer
→ max_steps

A better loop needs semantic exit conditions:

continue only if:
  new information was added
  a new action is available
  the verifier gave actionable feedback
  the state is not repeating

otherwise:
  abstain
  ask for human input
  or stop with a clear stop reason

So I would treat the stop policy as a first-class part of the framework, not as an implementation detail.

Pitfall 2: relying only on “reflect harder”

I would distinguish reflection text from a verification signal.

Reflection-style loops can be useful, but a verifier is much stronger if it has explicit criteria, tool results, tests, retrieval evidence, or a separate judge. Otherwise the system may simply ask the same model to reconsider without adding new information.

There is also research showing that LLM self-correction without external feedback can be unreliable in reasoning settings, for example Large Language Models Cannot Self-Correct Reasoning Yet. I would not read that as “all reflection is useless”. I would read it as:

unstructured self-correction is weak; explicit verification is safer.

That is why I would give the verifier a visible rubric.

Pitfall 3: tool schema and model tool-syntax ability

I would separate three different questions:

  1. Does the controller/tool plumbing work?
  2. Can the chosen model follow the required tool syntax?
  3. Does the loop improve task performance?

Those are different questions.

A small local model can be useful for sanity checks, but it may fail at tool syntax before it actually tests the framework idea. If a small model fails to emit the correct code block or JSON tool call, that does not necessarily mean the controller design is wrong.

For an early prototype, I would first confirm the framework with either:

  • rule-based components,
  • scripted model outputs,
  • very constrained prompts,
  • or a stronger tool-following model,

before interpreting failures as conceptual failures.

Pitfall 4: code execution boundaries

If using CodeAgent, I would be careful not to accidentally turn a conceptual prototype into an unsafe code-execution agent.

For the first pass, I would use:

allowed:
  safe toy tools
  hard-coded context lookup
  JSON trace logging
  deterministic verifier

not allowed at first:
  shell
  browser
  arbitrary filesystem writes
  credentials
  private data access
  broad network access

That keeps the first artifact about the reasoning loop, not about operational security.


6. A small thing that would make feedback easier

If you keep developing this, I do not think the next material needs to be a polished benchmark or Space.

Even one or two tiny trace examples would make feedback easier:

task
→ initial candidate
→ anomaly flags
→ action taken
→ verifier result
→ final answer or abstain
→ stop reason

A repo or Space could be useful later, but I would not treat packaging as the first requirement. The first useful thing is making the loop inspectable.

Something as small as this would already help future readers:

{
  "task": "toy shipping decision",
  "initial_candidate": "ship now",
  "anomaly_flags": {
    "contradiction": true
  },
  "action": "revise",
  "verifier_result": "reject",
  "final_candidate": "delay release until review is complete",
  "stop_reason": "accepted"
}

That gives other people something concrete to discuss without requiring a large implementation.


7. Possible staged path

One lightweight path could be:

Stage Goal Tooling
1 make the loop inspectable plain Python / JSON traces
2 make it agentic smolagents with restricted tools
3 make routing explicit optional LangGraph version
4 test on tiny scoreable tasks Reasoning Gym / OpenEnv
5 custom metrics LightEval
6 larger demos Space or repo, only if useful

I would keep the first version deliberately small.

The first milestone is not:

“This framework improves reasoning.”

It is:

“This framework produces readable, bounded, verifiable traces.”

That is a much easier claim to inspect.

If you publish even a minimal traceable version, I think people can give much more concrete feedback. The concept is easier to discuss once the loop has visible state, verifier criteria, and stop reasons.

Thanks for such a detailed response, yeah I guess that’s the flaw with it it has no way to check and self correct. I’d have to look into how actual architecture works. I took two years of computer Science and that’s about the extent of my knowledge. It’s just adaptation and understanding of incoming knowledge and how it corrects, but I think how you described it would definitely make something happen to complete the loop. I was thinking of using llms to utilize my ideas for a integral check among other practicalities. Similiar to how functions operate among a class, but utilizing logic gates as a process of information of weight. Or a baseline understanding of how to check systems function in order to point towards stored information. Idk it’s getting over my head but this is what I’ve come to understand so far, from an idea from hitchhiker’s guide to the galaxy. I’m just wondering if it’s something that can actually be built, but it needs those core definitions and a way to check it, without just overflowing in a loop like how you described. This is my imagination of it anyway so far.

Well. Probably, understanding the internal LLM architecture is not the priority in this case:


Yes, I think a small version of this can actually be built.

What you are describing currently looks less like a new internal transformer architecture and more like an external control architecture or protocol around an LLM. That is not a downgrade—it is probably the easier and more testable place to begin.

The LLM could be one component that interprets information or proposes an answer, while ordinary code controls:

  • the current state,
  • stored information,
  • the checks being performed,
  • routing between stages,
  • verification,
  • and the conditions for stopping.

I would also separate three ideas that can sound similar but behave differently in an implementation:

Term Practical meaning
Model weights Learned numerical parameters inside the neural network
Evidence weights or scores Values your controller assigns to evidence, confidence, priority, or risk
Logic gates Explicit rules or branches that decide what happens next

So your “logic gate matrix” does not initially need to manipulate the model’s internal weights. It could begin as ordinary rules:

IF evidence is missing:
    request or retrieve more context

IF the candidate contradicts stored evidence:
    reject or revise it

IF the same state repeats:
    stop the loop

IF no new information is available:
    abstain or ask for human input

IF the integrity check accepts the candidate:
    finalize the result

That would already let you test the central idea.

A minimal version might contain five components:

1. State
   What is currently known?
   What has already been attempted?

2. Worker
   Produces a candidate interpretation or answer.

3. Observer
   Checks for missing evidence, contradictions, repeated states,
   or other anomalies.

4. Verifier / integrity check
   Accepts, rejects, or requests revision using explicit criteria.

5. Controller
   Chooses whether to continue, retrieve more context, revise,
   abstain, ask a human, or stop.

The loop could be as simple as:

for step in range(max_steps):
    candidate = worker(state)
    anomalies = observer(state, candidate)
    verdict = verifier(state, candidate, anomalies)

    if verdict == "accept":
        return candidate

    if verdict in {"no_new_information", "repeated_state"}:
        return "ABSTAIN"

    state = controller_update(state, candidate, anomalies, verdict)

return "STOPPED: max steps reached"

The important part is not the specific code. It is defining the contract for each box in the diagram:

  • What does it receive?
  • What does it return?
  • What state can it change?
  • What causes it to activate?
  • What causes it to stop?
  • What evidence does it use?
  • What happens if it cannot decide?

Your “integrity check” could initially be a deterministic rule-based verifier. Later it could use an LLM, another model, retrieval results, tests, or several checks together. Starting with explicit rules makes it easier to tell whether the protocol works before model behavior adds more uncertainty.

So I would not start by studying or modifying attention layers, training procedures, or neural-network weights. Those become relevant only if the eventual goal is to change how the model itself computes internally.

For the current idea, a plain Python state machine is enough to test the core loop. Once the definitions and stop conditions behave sensibly, the same structure could be moved into an agent framework.

The first useful milestone would simply be:

Given an input, can the system show what it checked, why it continued, what changed, and why it eventually accepted, abstained, or stopped?

If it can do that consistently, then the main conceptual loop is already real enough to investigate further.