▲ 29 r/matlab
"Agents are just LLM + loop + tools" - I built it with MATLAB + Ollama
This is a lightweight AI coding agent built entirely in MATLAB. The core part is just a few lines of code.
chat = openAIChat(systemPrompt, Tools=tools); % configure the LLM
messages = messageHistory; % conversation history
while true % agentic loop
[text, response] = generate(chat, messages); % call the LLM
messages = addResponseMessage(messages, response);
if isempty(text)
results = run_tools(response); % execute requested tools
messages = addToolMessage(messages, results);
else
disp(text); % no more tool calls — done
break
end
end
That's it.
In practice, this is way too slow on my machine - no powerful GPU - to be practical (I sped up the video), and you are better off using frontier models. But if you have a very powerful machine and are willing to run local LLMs via LLMs with MATLAB Add-on, it's possible.
u/Creative_Sushi — 4 days ago