Spaces:
Running
Running
Sync Space session state naming
Browse files- README.md +2 -2
- agent_base/react_agent.py +1 -1
- agent_base/session_state.py +6 -3
README.md
CHANGED
|
@@ -65,7 +65,7 @@ These behaviors are intentional Space-only deltas:
|
|
| 65 |
managed run directory under `RH_SPACE_RUNS_DIR`.
|
| 66 |
- The runtime layout is always:
|
| 67 |
`run_.../agent_workspace/` for agent-visible files and
|
| 68 |
-
`run_.../agent_trace/` for traces and `
|
| 69 |
- Uploaded images are saved under `agent_workspace/inputs/images/` and are also
|
| 70 |
passed to the model as image inputs when supported.
|
| 71 |
- Users can download files created or handled by the agent with the
|
|
@@ -133,7 +133,7 @@ Configure these as Hugging Face Space secrets before starting the app:
|
|
| 133 |
βββ run_YYYYMMDD_HHMMSS_<random>/
|
| 134 |
βββ agent_workspace/
|
| 135 |
β βββ inputs/images/ # user uploaded images, when present
|
| 136 |
-
βββ agent_trace/ # trace JSONL and
|
| 137 |
```
|
| 138 |
|
| 139 |
The frontend exposes the chat UI and a single `Download workspace.zip` action
|
|
|
|
| 65 |
managed run directory under `RH_SPACE_RUNS_DIR`.
|
| 66 |
- The runtime layout is always:
|
| 67 |
`run_.../agent_workspace/` for agent-visible files and
|
| 68 |
+
`run_.../agent_trace/` for traces and `session_state_*.json`.
|
| 69 |
- Uploaded images are saved under `agent_workspace/inputs/images/` and are also
|
| 70 |
passed to the model as image inputs when supported.
|
| 71 |
- Users can download files created or handled by the agent with the
|
|
|
|
| 133 |
βββ run_YYYYMMDD_HHMMSS_<random>/
|
| 134 |
βββ agent_workspace/
|
| 135 |
β βββ inputs/images/ # user uploaded images, when present
|
| 136 |
+
βββ agent_trace/ # trace JSONL and session_state_*.json
|
| 137 |
```
|
| 138 |
|
| 139 |
The frontend exposes the chat UI and a single `Download workspace.zip` action
|
agent_base/react_agent.py
CHANGED
|
@@ -913,7 +913,7 @@ class MultiTurnReactAgent(BaseAgent):
|
|
| 913 |
on_event=event_callback,
|
| 914 |
)
|
| 915 |
self.trace_path = trace_writer.path
|
| 916 |
-
self.session_state_path = resolve_session_state_path(
|
| 917 |
session_state = AgentSessionState(
|
| 918 |
run_id=trace_writer.run_id,
|
| 919 |
model_name=self.model,
|
|
|
|
| 913 |
on_event=event_callback,
|
| 914 |
)
|
| 915 |
self.trace_path = trace_writer.path
|
| 916 |
+
self.session_state_path = resolve_session_state_path(self.trace_path) if self.trace_path else None
|
| 917 |
session_state = AgentSessionState(
|
| 918 |
run_id=trace_writer.run_id,
|
| 919 |
model_name=self.model,
|
agent_base/session_state.py
CHANGED
|
@@ -9,7 +9,7 @@ from agent_base.model_profiles import ModelProfile
|
|
| 9 |
from agent_base.utils import safe_jsonable
|
| 10 |
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
|
| 15 |
@dataclass
|
|
@@ -74,8 +74,11 @@ class AgentSessionState:
|
|
| 74 |
}
|
| 75 |
|
| 76 |
|
| 77 |
-
def resolve_session_state_path(
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
|
| 81 |
def persist_session_state(path: str | Path, state: AgentSessionState) -> None:
|
|
|
|
| 9 |
from agent_base.utils import safe_jsonable
|
| 10 |
|
| 11 |
|
| 12 |
+
SESSION_STATE_PREFIX = "session_state"
|
| 13 |
|
| 14 |
|
| 15 |
@dataclass
|
|
|
|
| 74 |
}
|
| 75 |
|
| 76 |
|
| 77 |
+
def resolve_session_state_path(trace_path: str | Path) -> Path:
|
| 78 |
+
trace = Path(trace_path)
|
| 79 |
+
stem = trace.stem
|
| 80 |
+
suffix = stem[len("trace_") :] if stem.startswith("trace_") else stem
|
| 81 |
+
return trace.with_name(f"{SESSION_STATE_PREFIX}_{suffix}.json")
|
| 82 |
|
| 83 |
|
| 84 |
def persist_session_state(path: str | Path, state: AgentSessionState) -> None:
|