MCPcopy Create free account
hub / github.com/AbhinavTheDev/coding-agent / validate

Function validate

agent/my_agent/agent.py:49–59  ·  view source on GitHub ↗
(state: CodeState)

Source from the content-addressed store, hash-verified

47 }
48
49def validate(state: CodeState):
50 # default value for iterations if not present
51 iterations = state.get("iterations", 0)
52 try:
53# Only try to execute if it looks like Python code
54 if state["code"].strip() and not state["code"].startswith(('Hello', 'Hi')):
55 exec(state["code"])
56 return {**state, "error": "", "iterations": iterations}
57 return {**state, "error": "", "iterations": iterations}
58 except Exception as e:
59 return {**state, "error": str(e), "iterations": iterations + 1}
60
61def route(state: CodeState):
62 # Only retry if there's an error and haven't exceeded max attempts

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected