(state: CodeState)
| 47 | } |
| 48 | |
| 49 | def 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 | |
| 61 | def route(state: CodeState): |
| 62 | # Only retry if there's an error and haven't exceeded max attempts |
nothing calls this directly
no outgoing calls
no test coverage detected