ShVaSa Blog
Systems & RL • 5 min read

My AI Agent Rejected 90% of Its Own Ideas, and That's Why It Won 🏆

Published on 2026-11-21 by Sharath Japa, ShVaSa Lab Lead
systemsarchitectureinfrastructureperformance
Discuss on r/shvasa

Executive Summary

The premise that an AI agent "rejected 90% of its own ideas" is not a failure of creativity, but a successful implementation of a high-threshold rejection sampling mechanism within a constrained inference loop. In autonomous agent architectures, particularly those utilizing Large Language Models (LLMs) for planning and execution, the primary bottleneck is not computational throughput, but the cost of hallucination and the latency of invalid state transitions. By implementing a rigorous self-critique layer that operates as a gatekeeper before tool invocation or code execution, we effectively filter out low-probability or logically inconsistent trajectories. This approach transforms the agent from a generative chaos engine into a deterministic planner. The "win" described in the context is achieved by reducing the effective search space of the agent's decision tree, thereby lowering token consumption, minimizing error rates in downstream execution, and ensuring that only high-confidence, syntactically valid, and semantically coherent actions are committed to the system state. This article dissects the algorithmic design of such a rejection filter, the specific system-level bottlenecks it resolves, and provides a reproducible implementation pattern.

Implementation Architecture

The core challenge in building robust AI agents is the "generate-and-test" loop. Traditional agents generate a plan, execute it, and only then discover if it fails. This is computationally expensive and often leads to cascading failures. The optimized architecture introduces a pre-execution validation phase. This phase does not rely on the LLM's generative capabilities alone but employs a structured critique protocol.

The system consists of three distinct components:

  1. The Generator: The primary LLM tasked with proposing a course of action (e.g., a code snippet, an API call, or a logical step).
  2. The Critic (Rejector): A secondary, often smaller or more specialized model, or a rule-based heuristic engine, that evaluates the generator's output against a strict set of constraints. These constraints include syntax validity, logical consistency, security policy compliance, and resource usage estimates.
  3. The State Manager: A persistent memory layer that tracks the history of rejected and accepted ideas, allowing the generator to learn from previous failures within the same context window.

The rejection rate of 90% indicates a highly selective filter. This is desirable because it forces the generator to produce higher-quality initial proposals or provides the system with immediate feedback to refine the prompt. The bottleneck here is typically memory bandwidth when loading large context windows for the critic, and scheduling latency when waiting for the critic's response. To mitigate this, the critic can be implemented as a lightweight script or a quantized model that runs locally, ensuring low-latency feedback.

PYTHON
import json
import logging
from typing import List, Dict, Any

# Mocking the LLM interface for demonstration
class AIAgent:
    def __init__(self, generator_model, critic_model):
        self.generator = generator_model
        self.critic = critic_model
        self.rejection_log = []
        self.max_retries = 5

    def propose_action(self, task: str) -> Dict[str, Any]:
        """Generate a candidate action."""
        prompt = f"Propose an action for: {task}"
        return self.generator.generate(prompt)

    def validate_action(self, action: Dict[str, Any]) -> bool:
        """
        The core rejection mechanism. 
        Returns False if the action is rejected.
        """
        # 1. Syntax Check
        if not self._check_syntax(action.get('code')):
            return False
        
        # 2. Logic Check (Mocked)
        if not self._check_logic(action.get('plan')):
            return False
            
        # 3. Security Policy Check
        if self._check_security(action.get('api_calls')):
            return False
            
        return True

    def _check_syntax(self, code: str) -> bool:
        # Simplified syntax validation
        return code and "import" in code  # Placeholder for AST parsing

    def _check_logic(self, plan: str) -> bool:
        # Placeholder for logical consistency check
        return len(plan) > 10

    def _check_security(self, api_calls: List[str]) -> bool:
        # Placeholder for security policy check
        return True

    def execute(self, task: str) -> Dict[str, Any]:
        """Main loop with rejection sampling."""
        attempts = 0
        while attempts < self.max_retries:
            candidate = self.propose_action(task)
            
            if self.validate_action(candidate):
                logging.info(f"Action accepted after {attempts} rejections.")
                return candidate
            
            self.rejection_log.append(candidate)
            attempts += 1
            # Refine prompt based on previous rejection
            task = f"{task}. Previous attempt failed. Be more specific."
            
        raise Exception("Max retries exceeded")

ShVaSa Intuition

The intuition behind rejecting 90% of ideas lies in the concept of information density and error propagation. In complex systems, a single invalid action can corrupt the entire state, requiring a full rollback. By rejecting low-quality ideas early, we preserve the integrity of the system state. The "win" is not in the number of ideas generated, but in the efficiency of the final solution.

This approach aligns with the principles of constrained decoding and self-correction. Instead of relying on the model to get it right the first time (which is statistically improbable for complex tasks), we build a system that expects failure and corrects it rapidly. The high rejection rate is a feature, not a bug, as it indicates that the filter is working correctly to exclude invalid or suboptimal paths.

The system's performance is governed by the trade-off between the cost of rejection (latency, token usage) and the cost of execution (error recovery, user dissatisfaction). By optimizing the critic to be fast and accurate, we minimize the former while maximizing the latter. This results in a more robust, predictable, and efficient AI agent.

graph TD
    A[User Task] --> B[Generator Model]
    B --> C{Critic Filter}
    C -- Reject --> D[Log Rejection]
    D --> E[Refine Prompt]
    E --> B
    C -- Accept --> F[Execute Action]
    F --> G[Update State]
    G --> H[Final Output]
    
    style C fill:#f9f,stroke:#333,stroke-width:2px
    style B fill:#bbf,stroke:#333,stroke-width:2px
    style F fill:#bfb,stroke:#333,stroke-width:2px

The flowchart above illustrates the iterative nature of the agent's decision-making process. The Generator proposes an idea, which is immediately subjected to the Critic Filter. If the idea is rejected, the system logs the failure and refines the prompt, feeding it back into the Generator. This loop continues until a valid action is found or the maximum retry limit is reached. The Critic Filter is the critical component that ensures only high-quality actions proceed to execution, thereby preventing state corruption and improving overall system reliability. This architecture is particularly effective in scenarios where the cost of error is high, and the need for deterministic outcomes is paramount.

<!-- Consensus Verified by Student (qwen3.6-35b-a3b) & Judge (gemma-4-31b-it) | VERIFICATION REPORT -->


Grounding & Source Attribution

Author Avatar

Sharath Japa, ShVaSa Lab Lead

Systems & AI Infrastructure Researcher, DGX Station homelab lead. Engineering RL environments, edge silicon inference, and local reasoning model distillation. Verified Profiles: Google Scholar • Google Patents • LinkedIn • GitHub (@sharathjapa) • Medium • r/shvasa.


Canonical Source: https://shvasa.us/posts/my-ai-agent-rejected-90-of-its-own-ideas-and-thats-why-it-won

Advertisement

Related Research & Architectural Blueprints