-
Notifications
You must be signed in to change notification settings - Fork 1
feat: agent runtime online + minimal safety spine (runtime root) #2003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
725865d
feat: add deterministic ScriptedDriver and consolidate scripted test …
Aureliolo bdae7d4
feat: add agent-engine worker execution service and runtime builder
Aureliolo 6dc8abc
feat: reject task creation in empty-company mode (no provider)
Aureliolo 06d15ff
feat: hot-swap worker execution service on setup-reinit (live provide…
Aureliolo 587dbc0
refactor: correct stale WorkerExecutionService docstrings
Aureliolo aad60a9
feat: install agent runtime at boot behind the provider switch
Aureliolo 12f151a
fix: resolve pre-pr review findings for agent runtime online
Aureliolo 49d9962
fix: babysit round 1, 11 findings (5 coderabbit, 4 gemini, 2 ci)
Aureliolo f745bd4
fix: babysit round 2, 4 findings (4 coderabbit)
Aureliolo 45cbbf3
fix: babysit round 3, 5 findings (5 coderabbit)
Aureliolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| from collections.abc import Callable # noqa: TC003 | ||
| from datetime import UTC, datetime | ||
| from pathlib import Path | ||
| from typing import Any | ||
| from typing import Any, Final | ||
|
|
||
| # ``ChannelsPlugin`` appears in the public signatures of the helpers | ||
| # below. Under PEP 649 lazy annotations, ``typing.get_type_hints()`` | ||
|
|
@@ -45,6 +45,9 @@ | |
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
| _AGENT_WORKSPACES_SUBDIR: Final[str] = "agent-workspaces" | ||
| _POSTGRES_VOLUME_DATA_DIR: Final[str] = "/data" | ||
|
|
||
|
|
||
| def _make_expire_callback( | ||
| channels_plugin: ChannelsPlugin, | ||
|
|
@@ -104,7 +107,7 @@ def _resolve_artifact_dir_env() -> str: | |
| """ | ||
| artifact_dir_str = os.environ.get("SYNTHORG_ARTIFACT_DIR", "").strip() | ||
| if not artifact_dir_str: | ||
| return "/data" | ||
| return _POSTGRES_VOLUME_DATA_DIR | ||
| artifact_path = Path(artifact_dir_str) | ||
| if not artifact_path.is_absolute(): | ||
| msg = ( | ||
|
|
@@ -123,6 +126,41 @@ def _resolve_artifact_dir_env() -> str: | |
| return artifact_dir_str | ||
|
|
||
|
|
||
| def resolve_agent_workspace_root_env() -> Path | None: | ||
| """Resolve the agent sandbox workspace root from the environment. | ||
|
|
||
| Returns ``<runtime data dir>/agent-workspaces`` when an env-driven | ||
| deployment is in effect, so the agent's file-system / sandbox tools | ||
| write onto the mounted data volume rather than a process temp dir. | ||
| Returns ``None`` for injected / dev apps (no deployment env vars), | ||
| where :attr:`AppState.agent_workspace_root` keeps its documented | ||
| process-stable temp fallback. | ||
|
|
||
| Precedence mirrors the persistence env resolution: | ||
| ``SYNTHORG_ARTIFACT_DIR`` (explicit), then ``SYNTHORG_DB_PATH`` | ||
| parent (sqlite volume), then ``/data`` when only | ||
| ``SYNTHORG_DATABASE_URL`` is set (postgres compose volume). | ||
| """ | ||
| artifact_dir = os.environ.get("SYNTHORG_ARTIFACT_DIR", "").strip() | ||
| if artifact_dir: | ||
| return Path(_resolve_artifact_dir_env()) / _AGENT_WORKSPACES_SUBDIR | ||
| db_path = os.environ.get("SYNTHORG_DB_PATH", "").strip() | ||
| if db_path: | ||
| db_path_obj = Path(db_path) | ||
| if not db_path_obj.is_absolute(): | ||
| msg = ( | ||
| f"SYNTHORG_DB_PATH={db_path!r} must be an absolute path when " | ||
| f"deriving the agent workspace root so sandbox writes land on " | ||
| f"the mounted data volume, not the process working directory" | ||
| ) | ||
| logger.warning(API_APP_STARTUP, error=msg, reason="non_absolute_db_path") | ||
| raise ValueError(msg) | ||
| return db_path_obj.parent / _AGENT_WORKSPACES_SUBDIR | ||
| if os.environ.get("SYNTHORG_DATABASE_URL", "").strip(): | ||
| return Path(_POSTGRES_VOLUME_DATA_DIR) / _AGENT_WORKSPACES_SUBDIR | ||
| return None | ||
|
Comment on lines
+129
to
+161
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The string "agent-workspaces" is hardcoded and repeated three times in this function. Additionally, "/data" is a hardcoded path. Per the "no-hardcoded-values" rule in CLAUDE.md, these should be defined as constants to improve maintainability and adhere to project standards. _AGENT_WORKSPACE_DIR: Final[str] = "agent-workspaces"
_DEFAULT_DATA_DIR: Final[str] = "/data"
def resolve_agent_workspace_root_env() -> Path | None:
"""Resolve the agent sandbox workspace root from the environment.
Returns <runtime data dir>/agent-workspaces when an env-driven
deployment is in effect, so the agent's file-system / sandbox tools
write onto the mounted data volume rather than a process temp dir.
Returns None for injected / dev apps (no deployment env vars),
where AppState.agent_workspace_root keeps its documented
process-stable temp fallback.
Precedence mirrors the persistence env resolution:
SYNTHORG_ARTIFACT_DIR (explicit), then SYNTHORG_DB_PATH
parent (sqlite volume), then /data when only
SYNTHORG_DATABASE_URL is set (postgres compose volume).
"""
artifact_dir = os.environ.get("SYNTHORG_ARTIFACT_DIR", "").strip()
if artifact_dir:
return Path(_resolve_artifact_dir_env()) / _AGENT_WORKSPACE_DIR
db_path = os.environ.get("SYNTHORG_DB_PATH", "").strip()
if db_path:
return Path(db_path).parent / _AGENT_WORKSPACE_DIR
if os.environ.get("SYNTHORG_DATABASE_URL", "").strip():
return Path(_DEFAULT_DATA_DIR) / _AGENT_WORKSPACE_DIR
return NoneReferences
|
||
|
|
||
|
|
||
| def _make_meeting_publisher( | ||
| channels_plugin: ChannelsPlugin, | ||
| ) -> Callable[[str, dict[str, Any]], None]: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.