В разборе Codemode Армин Ронахер показал, как Pi, оболочка для ИИ-агента, позволяет запускать вызовы инструментов параллельно и обрабатывать их результаты кодом JavaScript. Codemode — способ вызывать инструменты из кода JavaScript на стороне программы, которая управляет агентом.

В Pi этот код работает в отдельной изолированной среде без прямого доступа к сети и файловой системе. Код может обращаться к инструментам и сохранять данные для следующих вызовов в том же сеансе.

По оценке Ронахера, подход ещё нужно доработать для небольших моделей и работы с изображениями и двоичными данными.

Проверка утверждений:

  • Армин Ронахер опубликовал разбор Codemode с примерами из реальных сеансов Pi. (подтверждено самой публикацией: доказательство; «So now that we talked a bunch about it, it’s probably worth being a bit more explicit about it. Let’s walk ourselves through some invocations of Codemode of recent Pi sessions of mine. Note that none of this code is human written. It’s from real sessions of Pi, just re-indented for your viewing pleasure.»)
  • В Pi Codemode позволяет вызывать инструменты из JavaScript, выполнять вызовы параллельно и обрабатывать результаты кодом. (подтверждено самой публикацией: доказательство; «If you are not familiar with Codemode, it’s basically just a way to issue tool calls from within some language, in our case JavaScript. That allows you to compose those calls without necessarily going through the LLM’s context. Credit for naming goes to our friends at Cloudflare who coined it . For instance if you issue a bash call as a regular tool call in the LLM, then we only throw the trailing 2000 lines into the context and if the agent wants more, it needs to look at the overflow file itself. If however the agent issues that invocation via Codemode, then the Codemode side gets larger outputs sent structurally. Most importantly, because Codemode is JavaScript the agent can express concurrent operations and basic workflows. A common way in which you see agents now use this, is to first probe at 5-10 items from some tool response to see what it looks like, and to then write a Codemode script that processes the next n items.»)
  • В Pi код Codemode работает в отдельной изолированной среде без прямого доступа к сети и файловой системе. (подтверждено самой публикацией: доказательство; «Codemode runs in the harness, in its own sandbox. In case of Pi it’s running in QuickJS within a WASM runtime with intentional limitations: no network, no file system, no timers, limited RAM. The only way is to call more tools.»)
  • Код Codemode может обращаться к инструментам и сохранять данные для следующих вызовов в том же сеансе. (подтверждено самой публикацией: доказательство; «Codemode also allows you to throw state into the transcript! That means that one Codemode invocation can stash away data, that the next call in the session can load again. And remember: this is on the harness host, not the sandbox.»)
  • По оценке Ронахера, подход ещё нужно доработать для небольших моделей и работы с изображениями и двоичными данными. (подтверждено самой публикацией: доказательство; «Images, binary data and just the inability of this pattern to work with smaller models is also something that needs to be fleshed out. So it’s for sure not a perfect solution yet, but it’s quite a useful pattern that I expect us to leverage more.»)

Первоисточники:

оценка 51,5 из 100 · тип: разбор