Skip to content

Instantly share code, notes, and snippets.

View josefrichter's full-sized avatar

Josef Richter josefrichter

View GitHub Profile
@josefrichter
josefrichter / planning_memory.exs
Last active June 11, 2026 19:31
Minimal Part 3 in Elixir: a GenServer that holds the agent scratchpad + to-do list, with the planning tools calling into it; talks to local Ollama.
# planning_memory.exs — a long-task planning agent whose working memory (the
# SCRATCHPAD + TO-DO LIST) lives in its own GenServer, talking to a local Ollama.
#
# Part 3 of the "build an agent" tutorials gives the agent a scratchpad (to think)
# and a to-do list (to track multi-step work). In the Python original those are
# module-level globals. The Elixir-shaped home for that working memory is a
# GenServer: `MiniAgent.Memory` below — one process that OWNS the state. The
# planning tools are just calls into it.
#
# New to Elixir? The comments call out the language-specific bits, and mark the
@josefrichter
josefrichter / planning_agent.exs
Created June 11, 2026 18:25
Minimal long-task-planning AI agent in Elixir — a single GenServer that owns its scratchpad + to-do list (Part 3 of ruxu.dev's 'Build a Basic AI Agent From Scratch'), talking to local Ollama.
# planning_agent.exs — a long-task-planning agent in one small file of Elixir.
#
# This is Part 3 of Roger Oriol's "Build a Basic AI Agent From Scratch" series —
# the "long task planning" post — ported to Elixir, talking to a local Ollama.
# Part 3 gives the agent two things so it can stay on a long task instead of
# quitting after one step: a SCRATCHPAD (to think) and a TO-DO LIST (to track work).
#
# Why this is the Elixir-shaped version: in the Python original the scratchpad and
# to-do list are module-level *globals* — one set per interpreter, shared by
# everything. The natural home for "an agent's working memory" in Elixir is a
@josefrichter
josefrichter / README.md
Last active June 11, 2026 14:07
Tiny AI-agent harness in Elixir (loop + tools + long-task planning) for local Ollama — an Elixir port of ruxu.dev's 'Build a Basic AI Agent From Scratch' series, commented with why the BEAM fits an agent harness.

mini agent harness (Elixir + Ollama)

A tiny AI-agent harness in Elixir, talking to a local Ollama. It's an Elixir port of Roger Oriol's "Build a Basic AI Agent From Scratch" series (part 1, part 2: tools, part 3: long-task planning), rebuilt on OTP primitives. All three stages are here:

  • Part 1 — the loop: an LLM connection + message history + a loop
@josefrichter
josefrichter / stack.ex
Created December 13, 2021 11:10
Genserver: How to return errors from cast?
defmodule Stack do
use GenServer
# Client
def start_link(default) when is_list(default) do
GenServer.start_link(__MODULE__, default)
end
def push(pid, element) do
// doesn't throw error, but doesn't work:
const x = useTransform(
contentOffsetY,
[0, -400],
[0, endX],
[
{
clamp: false,
ease: [0.5],
export function ScaleV2(): Override {
const [endX, endScale, endOpacity] = [-60, 0.5, 0.6] // TODO pass this from outside
const x = useTransform(contentOffsetY, [0, -400], [0, endX], {
clamp: false,
})
const scale = useTransform(contentOffsetY, [0, -400], [1, endScale], {
clamp: false,
})
const opacity = useTransform(contentOffsetY, [0, -400], [1, endOpacity], {
@josefrichter
josefrichter / contracts...MyContract.sol
Created September 9, 2021 17:33
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract MyContract {
uint256 public peopleCount;
// Person[] public people;
mapping(uint => Person) public people;
struct Person {
@josefrichter
josefrichter / contracts...MyContract3.sol
Created September 9, 2021 17:32
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract MyContract {
uint256 public peopleCount;
mapping(uint => Person) public people;
address owner;
uint256 openingTime = 1631171503;
/// uint256 openingTime = 1631171803;
@josefrichter
josefrichter / contracts...MyContract4.sol
Created September 9, 2021 17:32
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract MyContract {
mapping(address => uint256) public balances;
address payable wallet;
event Purchase(
address indexed _buyer,
uint256 _amount
@josefrichter
josefrichter / contracts...MuyContract5.sol
Created September 9, 2021 17:32
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract ERC20Token {
string public name;
mapping(address => uint256) public balances;
function mint() public {
balances[tx.origin] ++;
}
}