Skip to content

[docs] Add Flame runtime integration design#1

Merged
k82cn merged 2 commits into
mainfrom
design/flame-runtime-integration
Feb 5, 2026
Merged

[docs] Add Flame runtime integration design#1
k82cn merged 2 commits into
mainfrom
design/flame-runtime-integration

Conversation

@k82cn

@k82cn k82cn commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds a comprehensive design document for integrating Firewood with Flame's runtime capabilities.

Key Features

1. Session Storage (FlameStorageBackend)

  • 1:1 session mapping: Firewood session ID = Flame session ID
  • Persist session metadata and messages to Flame's distributed cache
  • Global session index for listing all sessions

2. Remote Agent Execution (FlameAgentRunner)

  • Run AI agents on Flame executors using the Runner API
  • Support for stateful (conversation memory) and stateless (parallel queries) modes
  • Enhanced Runner API with auto-start (no context manager needed)
  • Explicit close() method for cleanup

3. SkillManager Enhancement

  • Auto-download all skills from xflops/skills GitHub repository
  • Download only when skills directory doesn't exist (caching)
  • Skills directory always set to working directory on executor

4. Security Model

  • Filesystem sandboxed to executor's working directory
  • Built-in functions (read_fs, write_fs, http_*, etc.) with configurable permissions
  • Optional read-only mode for extra security

Configuration

remote_config = RemoteAgentConfig(
    provider_config=provider_config,
    skills_enabled=True,              # Auto-downloads from xflops/skills
    builtin_functions_enabled=True,   # Enable read_fs, write_fs, http_*, etc.
    filesystem_read_only=False,       # Allow both read and write
)

runner = FlameAgentRunner("my-agent")
agent = runner.create_agent(remote_config, stateful=True)
response = agent.chat(messages)
runner.close()

Related

Implementation Plan

  • Phase 1: Storage Backend (Week 1)
  • Phase 2: SkillManager Enhancement (Week 1)
  • Phase 3: Remote Execution (Week 2)
  • Phase 4: Integration (Week 3)

This design document covers:

1. Session Storage (FlameStorageBackend)
   - 1:1 mapping between Firewood and Flame session IDs
   - Persist session metadata and messages to Flame cache
   - Global session index for listing sessions

2. Remote Agent Execution (FlameAgentRunner)
   - Run AI agents on Flame executors using Runner API
   - Support for stateful/stateless execution modes
   - Auto-start Runner (no context manager needed)

3. SkillManager Enhancement
   - Auto-download skills from xflops/skills repo
   - Download only if skills directory doesn't exist
   - Cache skills for subsequent runs

4. Security Model
   - Filesystem sandboxed to working directory
   - Built-in functions with configurable permissions
   - Read-only mode option

Related: flamepy Runner API enhancements (PR #341, #342)
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @k82cn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a design document outlining the integration of Firewood with the Flame runtime environment. The design focuses on enabling distributed session storage and remote agent execution, enhancing Firewood's scalability and capabilities. It details the architecture, data model, and implementation of key components such as FlameStorageBackend and FlameAgentRunner, along with security considerations and configuration options.

Highlights

  • Integration Design: This PR introduces a comprehensive design document detailing the integration of Firewood with Flame's runtime capabilities, focusing on session storage and remote agent execution.
  • Session Storage: The design includes a FlameStorageBackend that persists sessions using Flame's distributed object cache, ensuring sessions can be scaled and shared across machines.
  • Remote Agent Execution: The design incorporates a FlameAgentRunner to run AI agents remotely using Flame's Runner API, supporting both stateful and stateless modes with enhanced security features.
  • SkillManager Enhancement: The SkillManager is enhanced to automatically download skills from the xflops/skills GitHub repository if the skills directory does not exist, facilitating easier skill management.
  • Security Model: A robust security model is defined, sandboxing the filesystem to the executor's working directory and providing configurable permissions for built-in functions.
Changelog
  • docs/design/flame-runtime.md
    • Added a comprehensive design document for integrating Firewood with Flame's runtime capabilities.
    • Introduced FlameStorageBackend for persisting sessions using Flame's distributed object cache.
    • Implemented FlameAgentRunner for remote agent execution using Flame's Runner API.
    • Enhanced SkillManager to auto-download skills from the xflops/skills GitHub repository.
    • Defined a security model with filesystem sandboxing and configurable permissions.
Activity
  • The pull request adds a new design document detailing the integration of Firewood with Flame's runtime capabilities.
  • It outlines the architecture, data model, and implementation of key components such as FlameStorageBackend and FlameAgentRunner.
  • The design includes enhancements to the SkillManager and a robust security model.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is a comprehensive and well-structured design document for integrating Firewood with Flame. The proposed architecture for session storage and remote execution is clear. I've identified a couple of areas for improvement: a potential design flaw in the state management for stateful remote agents, and a security consideration regarding environment variable access. Addressing these points will help solidify the design.

Comment on lines +471 to +482
def chat(self, messages: list[dict]) -> str:
"""Process chat messages and return response."""
agent = self._ensure_agent()
msg_objects = [Message.from_dict(m) for m in messages]

# Collect streamed response
response_parts = []
for choice_idx, chunk, is_complete in agent.send_message(msg_objects[-1].content):
if choice_idx == 0: # Only use first choice
response_parts.append(chunk)

return "".join(response_parts)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The implementation of the chat method appears to have a logic issue concerning state management for stateful conversations. The usage example indicates that the client sends the entire message history with each call. However, this implementation only processes the content of the last message (msg_objects[-1].content).

Furthermore, the AgentManager instance (self._agent) is initialized without a Session object in _ensure_agent, which means it operates statelessly on each invocation. This contradicts the goal of a stateful agent that should maintain conversation memory.

To ensure stateful conversations work as intended, please clarify and adjust the design. One approach would be for the RemoteAgent to reconstruct the conversation state from the messages list on each call. Another would be to make the RemoteAgent truly stateful by creating and holding a Session object, which would require changing the chat method's signature to only accept the new message.

| `http_post` | HTTP POST request | Unrestricted (network access) |
| `http_put` | HTTP PUT request | Unrestricted (network access) |
| `http_delete` | HTTP DELETE request | Unrestricted (network access) |
| `get_env` | Read environment variable | Access to executor's env |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The get_env function, which provides access to the executor's environment variables, could introduce a security risk. The executor's environment might contain sensitive data, such as API keys or other credentials. To mitigate potential information leakage, consider restricting this function's access to an allowlist of safe environment variables.

- Remove unused installed_at parameter from test_skills.py
- Apply ruff formatting fixes across codebase
@k82cn k82cn merged commit 4222434 into main Feb 5, 2026
3 checks passed
@k82cn k82cn deleted the design/flame-runtime-integration branch February 5, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant