fix: persist workspace Python environments

This commit is contained in:
wuyang
2026-07-26 20:20:37 +08:00
parent bc30a480ad
commit 2fbb5698ac
14 changed files with 170 additions and 20 deletions
+9 -5
View File
@@ -6,7 +6,7 @@ from typing import Any
import httpx
from agent_platform.auth import UserIdentity
from agent_platform.auth import UserIdentity, issue_internal_identity
from agent_platform.config import Settings
from agent_platform.runtime.schemas import PlanItem
from agent_platform.store import RuntimeStore
@@ -117,12 +117,14 @@ TOOL_METADATA: dict[str, ToolMetadata] = {
"exec": ToolMetadata(
"exec",
"Run a complete non-interactive shell command. Name the script, pass -c code, or invoke a test; "
"bare python, node, or shells are rejected.",
"bare python, node, or shells are rejected. For Python dependencies, create or reuse "
"/workspace/.venv and install with .venv/bin/python -m pip; /tmp is not executable and the "
"read-only system Python must not be modified.",
object_schema(
{
"command": {"type": "string"},
"cwd": {"type": "string", "default": "."},
"timeout_seconds": {"type": "integer", "minimum": 1, "maximum": 1800, "default": 120},
"timeout_seconds": {"type": "integer", "minimum": 1, "maximum": 1800, "default": 900},
},
["command"],
),
@@ -266,7 +268,6 @@ READ_ONLY_TOOL_NAMES = {
@dataclass(frozen=True, slots=True)
class ToolContext:
identity: UserIdentity
raw_user_jwt: str
chat_id: str
@@ -298,7 +299,10 @@ class ToolRegistry:
f"{self.settings.gateway_url}{GATEWAY_ENDPOINTS[name]}",
headers={
"Authorization": f"Bearer {self.settings.internal_gateway_key}",
"X-OpenWebUI-User-Jwt": context.raw_user_jwt,
"X-OpenWebUI-User-Jwt": issue_internal_identity(
context.identity,
self.settings.openwebui_forward_jwt_secret,
),
},
json=arguments,
)