This repository has been archived on 2026-03-09. You can view files and clone it, but cannot push or open issues or pull requests.
php-agentic/Mcp/Tools/Agent/Session/SessionContinue.php
Snider 6f0618692a
Some checks failed
CI / PHP 8.3 (push) Failing after 2s
CI / PHP 8.4 (push) Failing after 2s
feat: add plan/session/phase/task Actions + slim MCP tools
Extract business logic from MCP tool handlers into 15 Action classes
(Plan 5, Session 5, Phase 3, Task 2) following the Brain pattern.
MCP tools become thin wrappers calling Action::run(). Add framework-level
REST controllers and routes as sensible defaults for consumers.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-04 13:58:45 +00:00

73 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Mod\Agentic\Mcp\Tools\Agent\Session;
use Core\Mod\Agentic\Actions\Session\ContinueSession;
use Core\Mod\Agentic\Mcp\Tools\Agent\AgentTool;
/**
* Continue from a previous session (multi-agent handoff).
*/
class SessionContinue extends AgentTool
{
protected string $category = 'session';
protected array $scopes = ['write'];
public function name(): string
{
return 'session_continue';
}
public function description(): string
{
return 'Continue from a previous session (multi-agent handoff)';
}
public function inputSchema(): array
{
return [
'type' => 'object',
'properties' => [
'previous_session_id' => [
'type' => 'string',
'description' => 'Session ID to continue from',
],
'agent_type' => [
'type' => 'string',
'description' => 'New agent type taking over',
],
],
'required' => ['previous_session_id', 'agent_type'],
];
}
public function handle(array $args, array $context = []): array
{
try {
$session = ContinueSession::run(
$args['previous_session_id'] ?? '',
$args['agent_type'] ?? '',
);
$inheritedContext = $session->context_summary ?? [];
return $this->success([
'session' => [
'session_id' => $session->session_id,
'agent_type' => $session->agent_type,
'status' => $session->status,
'plan' => $session->plan?->slug,
],
'continued_from' => $inheritedContext['continued_from'] ?? null,
'previous_agent' => $inheritedContext['previous_agent'] ?? null,
'handoff_notes' => $inheritedContext['handoff_notes'] ?? null,
'inherited_context' => $inheritedContext['inherited_context'] ?? null,
]);
} catch (\InvalidArgumentException $e) {
return $this->error($e->getMessage());
}
}
}