refactor(simulator): remove special-casing for input/output blocks

The simulator now has the block's run() source code via inspect.getsource(),
so it can figure out what any block does by reading the code. No need for
special isinstance checks for AgentInputBlock/AgentOutputBlock.
This commit is contained in:
Zamil Majdy
2026-03-29 06:28:09 +02:00
parent 93264b1177
commit 88fe1e9b5e

View File

@@ -10,8 +10,8 @@ Special cases (no LLM simulation needed):
(iterations capped to 1).
- AgentExecutorBlock executes for real so it can spawn child graph executions
(whose blocks are then simulated).
- AgentInputBlock (and all subclasses) and AgentOutputBlock are pure
passthrough -- they forward their input values directly.
- AgentInputBlock, AgentOutputBlock, and other simple blocks are simulated
using the same LLM prompt (which includes the block's run() source code).
- MCPToolBlock uses a specialised LLM prompt grounded in the tool's schema.
OrchestratorBlock and AgentExecutorBlock are handled in manager.py via
@@ -34,7 +34,6 @@ from collections.abc import AsyncGenerator
from typing import Any
from backend.blocks.agent import AgentExecutorBlock
from backend.blocks.io import AgentInputBlock, AgentOutputBlock
from backend.blocks.mcp.block import MCPToolBlock
from backend.blocks.orchestrator import OrchestratorBlock
from backend.util.clients import get_openai_client
@@ -388,32 +387,6 @@ async def simulate_block(
yield output
return
# Input/output blocks are pure passthrough -- they just forward their
# input values. No LLM simulation needed.
if isinstance(block, AgentInputBlock):
# AgentInputBlock and all subclasses (AgentDropdownInputBlock,
# AgentFileInputBlock, AgentShortTextInputBlock, etc.) yield
# "result" with the provided value.
value = input_data.get("value")
if value is None:
# Dry-run with no user input: generate a sensible default so
# downstream blocks (e.g. OrchestratorBlock) still receive data.
placeholder = input_data.get("placeholder_values")
if placeholder and isinstance(placeholder, list) and placeholder:
value = placeholder[0] # First dropdown option
else:
name = input_data.get("name", "input")
value = f"sample {name}"
yield "result", value
return
if isinstance(block, AgentOutputBlock):
# AgentOutputBlock passes through "value" as "output" (+ "name").
yield "output", input_data.get("value")
if "name" in input_data:
yield "name", input_data["name"]
return
output_schema = block.output_schema.jsonschema()
output_properties: dict[str, Any] = output_schema.get("properties", {})