GhostShell: Streaming LLM Function Calls for Concurrent Embodied Programming

Jian Gong, Youwei Huang, Bo Yuan, Ming Zhu, Zhou Liao, Jianhang Liang, Juncheng Zhan, Jinke Wang, Hang Shu, Mingyue Xiong, Yanjun Ye, Yufan Zu, Yang Zhou, Yihan Ding, Xuannian Chen, Xingyu Lu, Runjie Ban, Bingchao Huang, Fusen LiuarXiv 2025 · DOI

Abstract

GhostShell introduces a novel framework for embodied AI that enables real-time, concurrent robot control by streaming function calls directly from Large Language Models (LLMs). By utilizing an incremental XML-based token system and a multi-channel scheduler, GhostShell overcomes the latency and sequential limitations of traditional batch-processed JSON pipelines. Evaluation on the COCO quadruped robot demonstrates response times up to 66x faster than native LLM APIs while supporting complex, synchronized behaviors such as simultaneous speech and movement.

Introduction

Most current LLM-powered robots operate on a "plan-then-execute" pipeline. In this model, the robot receives a command, the LLM generates a complete plan (typically as a JSON block), and the robot only begins execution after the entire generation process is finished. This sequential approach creates a significant "robotic" lag that hinders natural human-robot interaction. Furthermore, coordinating multiple hardware components—such as a head, limbs, and speakers—is difficult under traditional models that struggle with concurrency. GhostShell addresses these challenges by treating robot control as a streaming programming task, allowing for "reasoning-while-acting."

The GhostShell Framework

The GhostShell architecture transforms the LLM into a streaming brain for the robot through four primary components:

  1. XML Function Tokens: Unlike JSON, which requires a closing brace for validation, XML's tag-based structure (e.g., <move speed="50" />) is naturally suited for incremental parsing. This allows the robot to trigger a function the moment a start tag appears in the LLM's output stream.
  2. Streaming Parser & Dynamic Mapper: A SAX-based parser extracts tokens on-the-fly, while a mapper connects these abstract tokens to concrete robot functions via dependency injection.
  3. Multi-Channel Scheduler: This component acts as an orchestra conductor, managing a Main Channel for global blocking actions (like speech) and multiple Sub-channels for independent hardware modules. This enables intra-channel synchronicity alongside inter-channel asynchronicity.
  4. Code-as-Prompt: Function signatures and documentation are fed directly into the system prompt, allowing the LLM to "write" the robot's behavior in real-time.
The GhostShell system architecture, illustrating the pipeline from LLM output stream to multi-channel execution.

Experimental Evaluation

The researchers evaluated GhostShell using COCO, a custom quadruped robot equipped with a camera, display, microphone, speaker, and four legs. The system was tested against a benchmark of 34 real-world interaction tasks, categorized into objective movements (e.g., "Triangle Walk"), subjective social interactions (e.g., "Expressing Sadness"), and long-horizon tasks requiring visual feedback (e.g., "Rock-Paper-Scissors").

The COCO quadruped robot platform used for evaluating the GhostShell framework.

Key Results and Insights

GhostShell demonstrates significant improvements in both speed and behavioral complexity:

  • Latency Reduction: The framework achieved a 66x faster response time for parallel execution tasks compared to native Claude-3.5-Sonnet function calling (90ms vs. 3,570ms).
  • Behavioral Accuracy: Using the Behavioral Correctness Metric (BCM), Claude-3.5-Sonnet achieved a state-of-the-art score of 0.85, while GPT-4o led in long-horizon multimodal tasks with a score of 0.8.
  • Fluid Interaction: By interleaving natural language and function tokens, the robot can explain its actions while performing them, mimicking human-like fluidity. The system also supports "Event-Driven Termination," allowing external interrupts to stop a streaming action mid-flow.

Discussion and Future Work

While GhostShell significantly advances real-time embodied AI, several challenges remain. As robot skill libraries grow, the system prompt may exceed LLM context limits, necessitating Retrieval-Augmented Generation (RAG). Additionally, current LLMs operate in half-duplex mode; moving toward full-duplex models would allow robots to incorporate environmental feedback during token generation. Finally, future work must address security concerns, as streaming code execution requires robust safety guardrails to prevent hazardous physical behaviors resulting from prompt injection.

Summary updated

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
COCO · 34-task behavioral evaluation suite on CoCoGhostShell with GPT-4.1Average Behavioral Correctness Metric (BCM)0.83model=GPT-4.1 · tasks=34
Source quote
L490: Avg. │ \multicolumn{3}{c|}{0.83} │ \multicolumn{3}{c|}{0.85} │ \multicolumn{3}{c|}{0.66} │ \multicolumn{3}{c}{0.65}
COCO · Parallel Exec. · move & head & earsGhostShell (function-token approach)Response time from model response to initiation of the first action90 ms-3480 vs baselinetask=parallel execution: move, head, ears · method=function-token approach
Source quote
L546: Parallel Exec. (move \ │ head \ │ ears) │ 90 │ 3,570 │ T │ T
COCO · Long-horizon multimodal tasks: Bottle Collision, Mirror GhostShell with GPT-4.1Average BCM0.8split: test · model=GPT-4.1 · tasks=Bottle Collision, Mirror Test, RPS Game
Source quote
L521: Avg. │ 0.8 │ 0.67 │ 0.37
COCO · Long-horizon multimodal tasks: Bottle Collision, Mirror GhostShell with Claude-4-SonnetAverage BCM0.67split: test · model=Claude-4-Sonnet · tasks=Bottle Collision, Mirror Test, RPS Game
Source quote
L521: Avg. │ 0.8 │ 0.67 │ 0.37
Reported baseline / comparator measurements (1)
BenchmarkMethodMetricScoreProtocol / Evidence
COCO · Parallel Exec. · move & head & earsClaude-4-Sonnet native function calls baselineResponse time from model response to initiation of the first action3,570 mstask=parallel execution: move, head, ears · model=Claude-4-Sonnet · method=native function calls
Source quote
L546: Parallel Exec. (move \ │ head \ │ ears) │ 90 │ 3,570 │ T │ T
BibTeX
@misc{gong2025ghostshell,
  author = {Jian Gong and Youwei Huang and Bo Yuan and Ming Zhu and Zhou Liao and Jianhang Liang and Juncheng Zhan and Jinke Wang and Hang Shu and Mingyue Xiong and Yanjun Ye and Yufan Zu and Yang Zhou and Yihan Ding and Xuannian Chen and Xingyu Lu and Runjie Ban and Bingchao Huang and Fusen Liu},
  title = {{GhostShell: Streaming LLM Function Calls for Concurrent Embodied Programming}},
  year = {2025},
  eprint = {2508.05298},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.05298},
}
Figure