Skip to content

Commit e374888

Browse files
committed
Rename agent_session to session and session_store to persistence
1 parent c365a16 commit e374888

32 files changed

Lines changed: 157 additions & 157 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ python_agent_harness/
188188
├── token_estimator.py # CJK-aware token estimation + calibration
189189
├── planmode.py # Plan/build modes + plan-file lifecycle
190190
├── prompts.py # Prompt loading + system-prompt assembly
191-
├── session_store.py # Session persistence + titles
192-
├── agent_session.py # AgentSession wiring hub + MCP lifecycle
191+
├── persistence.py # Session persistence + titles
192+
├── session.py # Session wiring hub + MCP lifecycle
193193
├── subagent.py # Sub-agent runner + error containment
194194
├── commands.py # Init/review/custom command definitions
195195
├── cli.py # CLI entry points

python_agent_harness/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"""python-agent-harness: a Python port of the gptel-agent-harness."""
22

3-
from .agent_session import AgentSession
43
from .mcp.config import MCPConfig, MCPServerConfig
54
from .mcp.manager import MCPManager
65
from .models import AgentMode, Message, ToolCall, ToolSpec
6+
from .session import Session
77

88
__version__ = "1.2.0"
99

1010
__all__ = [
11-
"AgentSession",
11+
"Session",
1212
"AgentMode",
1313
"MCPConfig",
1414
"MCPManager",

python_agent_harness/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(
8080
self.messages: list[Message] = messages if messages is not None else []
8181
self.top_level = top_level
8282
# an explicit per-run client (a dedicated clone for this
83-
# sub-agent invocation, see AgentSession.run_subagent) wins
83+
# sub-agent invocation, see Session.run_subagent) wins
8484
# over the session's shared sub-agent client
8585
self._client = client
8686
# fall back to the session's prompt so a run never loses it;

python_agent_harness/cli.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import sys
2020

2121
from . import config
22-
from .agent_session import AgentSession
2322
from .client import Client
23+
from .session import Session
2424
from .tools import default_registry
2525

2626

@@ -29,8 +29,8 @@ def make_session(
2929
config_path: str | None = None,
3030
model: str | None = None,
3131
stream: bool | None = None,
32-
) -> AgentSession:
33-
"""Create an AgentSession from config file + env (no env required).
32+
) -> Session:
33+
"""Create a Session from config file + env (no env required).
3434
3535
The system prompt defaults to the ported main-agent prompt
3636
(config.DEFAULT_AGENT_PROMPT_FILE); the sub-agent prompt always
@@ -71,8 +71,8 @@ def make_session(
7171
# same LLM log file — the TUI advertises the main client's log
7272
# path, and a separate sub-agent log would fragment debugging
7373
subagent_client.log_path = client.log_path
74-
from .agent_session import find_skill_dir
7574
from .prompts import assemble_agent_prompt, load_agent_prompt
75+
from .session import find_skill_dir
7676

7777
abs_project = os.path.abspath(project_dir)
7878
skill_dir = find_skill_dir(abs_project, paths.get("skill_path"))
@@ -97,7 +97,7 @@ def make_session(
9797
# instead of values drifted by earlier switches.
9898
llm_settings = dict(settings)
9999
llm_settings["stream"] = effective_stream
100-
return AgentSession(
100+
return Session(
101101
project_dir=abs_project,
102102
client=client,
103103
model=model,
@@ -128,8 +128,8 @@ def make_session_with_mcp(
128128
config_path: str | None = None,
129129
model: str | None = None,
130130
stream: bool | None = None,
131-
) -> AgentSession:
132-
"""Create an AgentSession and connect its configured MCP servers.
131+
) -> Session:
132+
"""Create a Session and connect its configured MCP servers.
133133
134134
Wraps ``make_session``: the session's MCP servers are connected and
135135
their tools registered before the session is returned (discovery

python_agent_harness/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def clone(self) -> Client:
237237
connection failure (or Ctrl-C abort) would tear down a
238238
sibling's in-flight request on the same client. Each
239239
concurrent sub-agent clones its own client (see
240-
``AgentSession.run_subagent``), keeping pools and the abort
240+
``Session.run_subagent``), keeping pools and the abort
241241
flag strictly per-request. The log file is shared so one
242242
session's LLM interactions stay in one log.
243243
"""

python_agent_harness/mcp/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
subprocess pipes, anyio memory streams — to a fresh loop each time and
77
break on the next call).
88
9-
Lifecycle (mirrors the session lifecycle; see ``AgentSession``)::
9+
Lifecycle (mirrors the session lifecycle; see ``Session``)::
1010
1111
manager = MCPManager(config)
1212
failures = manager.connect_all() # connect every configured server
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def title_from_filename(session_file: str) -> str | None:
9999
return title
100100

101101

102-
class SessionStore:
102+
class SessionPersistence:
103103
"""Saves/restores sessions for one agent session."""
104104

105105
def __init__(

python_agent_harness/prompts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def assemble_agent_prompt(
330330
parts: list[str] = []
331331
if include_context:
332332
# lazy import: harness imports this module at call time
333-
from .agent_session import find_context_dir
333+
from .session import find_context_dir
334334

335335
# the project's AGENTS.md files are just context files that live
336336
# outside the context directory — same block format, same section
@@ -464,7 +464,7 @@ def compact_summary(
464464
"""Ask the model to summarize *conversation* using the compact prompt.
465465
466466
Shared by the in-loop compaction (``AgentLoop.compact``) and the
467-
manual /compact command (``AgentSession.compact_conversation``).
467+
manual /compact command (``Session.compact_conversation``).
468468
Returns the summary text with the reasoning preamble stripped, or
469469
None when the response carries no text. Client exceptions
470470
propagate to the caller, which owns the failure handling
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""AgentSession: the runtime hub wiring tools, plan mode.
1+
"""Session: the runtime hub wiring tools, plan mode.
22
33
The session implements the ToolContext-facing API (sub-agents,
44
questions) and the agent-loop-facing API (client, calibrator, plan
@@ -20,9 +20,9 @@
2020
from .mcp.config import MCPConfig
2121
from .mcp.manager import MCPManager
2222
from .models import AgentMode
23+
from .persistence import SessionPersistence, escape_role_headers
2324
from .planmode import PlanMode
2425
from .prompts import index_skills
25-
from .session_store import SessionStore, escape_role_headers
2626
from .subagent import run_subagent
2727
from .token_estimator import TokenCalibrator
2828
from .tools import Registry, ToolContext
@@ -63,7 +63,7 @@ def find_context_dir(project_dir: str, configured: str | None = None) -> str | N
6363
return None
6464

6565

66-
class AgentSession:
66+
class Session:
6767
"""One interactive agent session (a "buffer" in elisp terms)."""
6868

6969
def __init__(
@@ -158,7 +158,7 @@ def __init__(
158158
# active clones are tracked so cancel()/close() can reach them.
159159
self._subagent_clients_lock = threading.Lock()
160160
self._active_subagent_clients: list[Client] = []
161-
self.store = SessionStore(
161+
self.store = SessionPersistence(
162162
project_dir=project_dir,
163163
model=model,
164164
backend=backend,

python_agent_harness/subagent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run_subagent(
3636
"""Run a sub-agent task; return a result string (never raises).
3737
3838
``client`` (when given) is the per-invocation dedicated client
39-
(see ``AgentSession.run_subagent``); the loop falls back to the
39+
(see ``Session.run_subagent``); the loop falls back to the
4040
session's shared sub-agent client otherwise.
4141
"""
4242
session = parent_session

0 commit comments

Comments
 (0)