Discussion

Show HN: A live Python REPL with an agentic LLM that edits and evaluates code

I built PyChat.ai, an open-source Python REPL written in Rust that embeds an LLM agent capable of inspecting and modifying the live Python runtime state.

A sample interaction:

    py> def succ(n):
    py>   n + 1
    py> succ(42)
    None
    ai> why is succ not working?
    
        Thinking...
        -> Listing globals
        <- Found 1 globals
        -> Inspecting: succ
        <- Inspection complete: function
        -> Evaluating: succ(5)
        <- Evaluated: None
        Tokens: 2102 in, 142 out, 2488 total
    
    The function `succ` is not working because it calculates the result (`n + 1`) but does not **return** it.
    
    In its current definition:
    ```python
    def succ(n):
        n + 1
    ```
    The result of the addition is discarded, and the function implicitly returns `None`. To fix it, you should add a
    `return` statement:
    ```python
    def succ(n):
        return n + 1
    ```
Unlike typical AI coding assistants, the model isn’t just generating text — it can introspect the interpreter state and execute code inside the live session.

Everything runs inside a Rust process embedding the Python interpreter, with a terminal UI where you can switch between Python and the agent via <tab>.

It’s very much a prototype, and definitely insecure, but I think the interaction model is interesting and potentially generalizable.

Source: https://github.com/andreabergia/pychat.ai

Blog post: https://andreabergia.com/blog/2026/02/pychat-ai/

4 points andreabergia 8 months ago 4 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton