CoCoOne commited on
Commit
49476b4
Β·
1 Parent(s): 59a9db7

Sync Space session state naming

Browse files
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 `_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,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 _session_state.json
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(trace_dir) if trace_dir else None
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
- SESSION_STATE_FILENAME = "_session_state.json"
13
 
14
 
15
  @dataclass
@@ -74,8 +74,11 @@ class AgentSessionState:
74
  }
75
 
76
 
77
- def resolve_session_state_path(trace_dir: str | Path) -> Path:
78
- return Path(trace_dir) / SESSION_STATE_FILENAME
 
 
 
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: