[docs] Add Flame runtime integration design#1
Conversation
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)
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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 | |
There was a problem hiding this comment.
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
Summary
This PR adds a comprehensive design document for integrating Firewood with Flame's runtime capabilities.
Key Features
1. Session Storage (
FlameStorageBackend)2. Remote Agent Execution (
FlameAgentRunner)close()method for cleanup3. SkillManager Enhancement
xflops/skillsGitHub repository4. Security Model
read_fs,write_fs,http_*, etc.) with configurable permissionsConfiguration
Related
Implementation Plan