Posted by fanuc_programmer_dan
I spend way too much time debugging KAREL code and I'm wondering if anyone has built a custom GPT or LLM agent that can actually help with this. The problem is KAREL is such a niche language that generic ChatGPT is basically useless, it hallucinates syntax and gives you code that won't even compile. I'm thinking about training or fine-tuning something on our internal KAREL codebase but I have no idea if that's realistic or even worth the effort. We have probably 200+ KAREL programs, mostly socket communication, motion control, and custom I/O handling. Has anyone done something similar for obscure industrial programming languages? Or am I better off just getting better at reading compiler errors lol.
Reply by fanuc_programmer_dan
Michelle that's really clever, using RAG instead of fine-tuning makes way more sense given how little KAREL code exists in the world. How did you handle the fact that KAREL has different versions with slightly different syntax? We have some R-30iB controllers and some newer R-30iB Plus and the KAREL implementations are subtly different. Also curious how you deal with compiler-specific errors - like when you get "TRAN-160 illegal variable declaration" or whatever and need to figure out what you actually did wrong. Can the LLM help with that or is it just guessing?
Reply by robotics_integrator_jeff
This is all interesting but I'm curious about the practical value. Like are you guys actually using this for production code or just learning/exploration? I've been burned too many times by AI-generated code that looks right but has subtle bugs. With KAREL especially, if you screw up motion commands or I/O timing you can crash a million dollar robot into something. Not trying to be negative just want to understand the risk management here. Do you have the LLM generate code and then you review it line by line, or are you trusting it more than that?
Reply by fanuc_programmer_dan
OK that makes sense, using it as a smart search tool rather than a code generator. I like the idea of the error database, we definitely have enough historical issues to populate that. Michelle how much effort was it to get all your KAREL code into a format the LLM could understand? A lot of our programs have binary dependencies or include files that reference hardware-specific configurations. Did you just strip all that out or try to preserve the full context?
Reply by automation_engineer_lisa
This thread has me thinking about doing something similar for Siemens SCL code which is equally obscure and poorly documented. One concern though - if you're embedding your company's proprietary KAREL code into OpenAI's systems aren't you potentially leaking IP? Or are you running local models? We're in automotive and our lawyers would have a fit if we sent our robot programs to external APIs. How are you handling the data privacy aspect?
Reply by ai_robotics_dev_michelle
Lisa great point. We're using Azure OpenAI which has data residency guarantees and doesn't train on customer data, plus we're in a region with GDPR compliance. That said, we still scrubbed anything truly proprietary before embedding - removed customer names, specific part numbers, trade secret processes, etc. Just kept the generic programming patterns and common debugging scenarios. For companies with stricter requirements you could use a local model like CodeLlama or Mistral, they're not as good but they work offline. There's also the option of using GitHub Copilot for Business which keeps your data isolated. Really depends on your risk tolerance and budget.
Reply by fanuc_programmer_dan
Alright I'm sold, going to try building a basic version of this with RAG and see how it goes. Thanks for all the detailed examples Michelle, super helpful. One last thing - have any of you tried using these LLM agents for translating between KAREL and other languages? Like we have some old robots running KAREL and newer ones with Python on embedded PCs, and sometimes we need to port functionality between them. Wondering if an LLM could help with that translation or if the semantic gap is too big.