refactor: plumb SessionId end-to-end + paste + event-context fixes #96

Merged
jasoncouture merged 12 commits from undoing-claudes-dumbass-bullshit into main 2026-05-20 00:07:38 -04:00
jasoncouture commented 2026-05-20 00:07:31 -04:00 (Migrated from github.com)

Summary

  • Replace (string agentId, Guid? sessionId) with SessionId across IContextStore, ArchiveId, persistence, data-context scope/factory, AgentInfo, IAgentContextProvider, IAgentDirectory, slash-command context, and ChannelMessage.
  • JsonLineContextStore resolves folder/file from SessionId.IsDefault: default → <agentId>/current.json; non-default → <agentId>/<name>/<sessionId:n>.json.
  • All agent/turn/fragment/lifecycle/command events stamp + subscribe by session canonical. Session-keyed subscribers opt into a new preserveSubscriberExecutionContext on IEventBus.Subscribe so their handler runs with the agent's ambient data scope.
  • Loopback bearer + claims projector carry the session canonical in NameIdentifier; middleware parses it back and joins the matching scope. AgentWorkspaceLocator parses the same claim so MCP tools resolve the agent's workspace instead of process cwd.
  • Chat UI tracks SelectedSession; slash commands consume context.Session; AgentInstanceRepository gains TryGetDefaultSession for UI/auth lookup.
  • Web fixes: composer paste handler pre-scans clipboard items so KDE pastes with a text/uri-list sibling don't kill image paste, and SignalR MaximumReceiveMessageSize bumped to 32 MB so a pasted image survives the round-trip.

Test plan

  • dotnet build
  • dotnet test
  • Manual: paste image into composer on KDE/Wayland.
  • Manual: /clear, /archive, /compact, /interrupt.
  • Manual: MCP shell + filesystem tools run in the agent workspace.
## Summary - Replace `(string agentId, Guid? sessionId)` with `SessionId` across `IContextStore`, `ArchiveId`, persistence, data-context scope/factory, `AgentInfo`, `IAgentContextProvider`, `IAgentDirectory`, slash-command context, and `ChannelMessage`. - `JsonLineContextStore` resolves folder/file from `SessionId.IsDefault`: default → `<agentId>/current.json`; non-default → `<agentId>/<name>/<sessionId:n>.json`. - All agent/turn/fragment/lifecycle/command events stamp + subscribe by session canonical. Session-keyed subscribers opt into a new `preserveSubscriberExecutionContext` on `IEventBus.Subscribe` so their handler runs with the agent's ambient data scope. - Loopback bearer + claims projector carry the session canonical in `NameIdentifier`; middleware parses it back and joins the matching scope. `AgentWorkspaceLocator` parses the same claim so MCP tools resolve the agent's workspace instead of process cwd. - Chat UI tracks `SelectedSession`; slash commands consume `context.Session`; `AgentInstanceRepository` gains `TryGetDefaultSession` for UI/auth lookup. - Web fixes: composer paste handler pre-scans clipboard items so KDE pastes with a text/uri-list sibling don't kill image paste, and SignalR `MaximumReceiveMessageSize` bumped to 32 MB so a pasted image survives the round-trip. ## Test plan - [ ] `dotnet build` - [ ] `dotnet test` - [ ] Manual: paste image into composer on KDE/Wayland. - [ ] Manual: `/clear`, `/archive`, `/compact`, `/interrupt`. - [ ] Manual: MCP shell + filesystem tools run in the agent workspace.
github-actions[bot] commented 2026-05-20 00:09:10 -04:00 (Migrated from github.com)
Package Line Rate Branch Rate Complexity Health
LlamaShears.Core.Eventing 92% 88% 58
LlamaShears.Core.Abstractions 51% 33% 464
LlamaShears.Api 30% 30% 475
LlamaShears.Provider.Ollama 44% 28% 188
LlamaShears.Core.Eventing.Extensions 100% 100% 1
LlamaShears.Core 45% 42% 1540
LlamaShears.Provider.Onnx.Embeddings 37% 38% 72
LlamaShears.Provider.OpenAI 66% 65% 229
LlamaShears.Api.Web 1% 1% 482
LlamaShears.Hosting 33% 21% 27
LlamaShears.Plugins 0% 100% 1
LlamaShears.Core.Eventing 90% 78% 58
LlamaShears 52% 36% 25
LlamaShears.Plugins.Host 34% 24% 36
LlamaShears.Core.Abstractions 44% 23% 464
LlamaShears.Api 6% 2% 475
LlamaShears.Provider.Ollama 3% 1% 188
LlamaShears.IntegrationTests.Fixtures 73% 57% 64
LlamaShears.Core.Eventing.Extensions 100% 100% 1
StrangeSoft.Plugins.Host 20% 21% 87
LlamaShears.Core 43% 28% 1540
LlamaShears.Provider.Onnx.Embeddings 3% 0% 72
LlamaShears.Provider.OpenAI 2% 0% 229
LlamaShears.Api.Web 20% 9% 482
LlamaShears.Hosting 26% 8% 27
LlamaShears.Plugins 0% 100% 1
LlamaShears.Core.Eventing 87% 74% 58
LlamaShears 52% 36% 25
LlamaShears.Plugins.Host 34% 24% 36
LlamaShears.Core.Abstractions 34% 21% 464
LlamaShears.Api 7% 3% 475
LlamaShears.Provider.Ollama 3% 1% 188
LlamaShears.IntegrationTests.Fixtures 70% 52% 64
LlamaShears.Core.Eventing.Extensions 100% 100% 1
StrangeSoft.Plugins.Host 20% 21% 87
LlamaShears.Core 31% 19% 1540
LlamaShears.Provider.Onnx.Embeddings 3% 0% 72
LlamaShears.Provider.OpenAI 2% 0% 229
LlamaShears.Api.Web 17% 7% 482
LlamaShears.Hosting 26% 8% 27
LlamaShears.Analyzers.CodeFixes 85% 69% 60
LlamaShears.Analyzers 88% 76% 199
Summary 45% (11433 / 34836) 36% (2476 / 10361) 11293
Package | Line Rate | Branch Rate | Complexity | Health -------- | --------- | ----------- | ---------- | ------ LlamaShears.Core.Eventing | 92% | 88% | 58 | ✔ LlamaShears.Core.Abstractions | 51% | 33% | 464 | ➖ LlamaShears.Api | 30% | 30% | 475 | ❌ LlamaShears.Provider.Ollama | 44% | 28% | 188 | ❌ LlamaShears.Core.Eventing.Extensions | 100% | 100% | 1 | ✔ LlamaShears.Core | 45% | 42% | 1540 | ❌ LlamaShears.Provider.Onnx.Embeddings | 37% | 38% | 72 | ❌ LlamaShears.Provider.OpenAI | 66% | 65% | 229 | ➖ LlamaShears.Api.Web | 1% | 1% | 482 | ❌ LlamaShears.Hosting | 33% | 21% | 27 | ❌ LlamaShears.Plugins | 0% | 100% | 1 | ❌ LlamaShears.Core.Eventing | 90% | 78% | 58 | ✔ LlamaShears | 52% | 36% | 25 | ➖ LlamaShears.Plugins.Host | 34% | 24% | 36 | ❌ LlamaShears.Core.Abstractions | 44% | 23% | 464 | ❌ LlamaShears.Api | 6% | 2% | 475 | ❌ LlamaShears.Provider.Ollama | 3% | 1% | 188 | ❌ LlamaShears.IntegrationTests.Fixtures | 73% | 57% | 64 | ➖ LlamaShears.Core.Eventing.Extensions | 100% | 100% | 1 | ✔ StrangeSoft.Plugins.Host | 20% | 21% | 87 | ❌ LlamaShears.Core | 43% | 28% | 1540 | ❌ LlamaShears.Provider.Onnx.Embeddings | 3% | 0% | 72 | ❌ LlamaShears.Provider.OpenAI | 2% | 0% | 229 | ❌ LlamaShears.Api.Web | 20% | 9% | 482 | ❌ LlamaShears.Hosting | 26% | 8% | 27 | ❌ LlamaShears.Plugins | 0% | 100% | 1 | ❌ LlamaShears.Core.Eventing | 87% | 74% | 58 | ✔ LlamaShears | 52% | 36% | 25 | ➖ LlamaShears.Plugins.Host | 34% | 24% | 36 | ❌ LlamaShears.Core.Abstractions | 34% | 21% | 464 | ❌ LlamaShears.Api | 7% | 3% | 475 | ❌ LlamaShears.Provider.Ollama | 3% | 1% | 188 | ❌ LlamaShears.IntegrationTests.Fixtures | 70% | 52% | 64 | ➖ LlamaShears.Core.Eventing.Extensions | 100% | 100% | 1 | ✔ StrangeSoft.Plugins.Host | 20% | 21% | 87 | ❌ LlamaShears.Core | 31% | 19% | 1540 | ❌ LlamaShears.Provider.Onnx.Embeddings | 3% | 0% | 72 | ❌ LlamaShears.Provider.OpenAI | 2% | 0% | 229 | ❌ LlamaShears.Api.Web | 17% | 7% | 482 | ❌ LlamaShears.Hosting | 26% | 8% | 27 | ❌ LlamaShears.Analyzers.CodeFixes | 85% | 69% | 60 | ✔ LlamaShears.Analyzers | 88% | 76% | 199 | ✔ **Summary** | **45%** (11433 / 34836) | **36%** (2476 / 10361) | **11293** | ❌ <!-- Sticky Pull Request Commentcoverage -->
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-05-20 00:13:47 -04:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

This PR refactors the codebase to use SessionId as the canonical identifier end-to-end (persistence, data scopes, auth claims, event routing, slash commands, and UI state), and includes web UI fixes for image paste and larger SignalR payloads.

Changes:

  • Replace agent/session tuple routing with SessionId across persistence (IContextStore, ArchiveId), data context (IDataContextScope/Factory), and agent snapshot APIs (IAgentContextProvider, AgentInfo).
  • Update eventing to publish/subscribe by session-canonical ids and add preserveSubscriberExecutionContext to IEventBus.Subscribe.
  • Web/UI updates: session selection in chat UI, improved clipboard paste handling, and increased SignalR message size limit.

Reviewed changes

Copilot reviewed 79 out of 79 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/LlamaShears.UnitTests/Context/AgentContextProviderTests.cs Updates unit tests to construct contexts via SessionId.
tests/LlamaShears.UnitTests/Api/Authentication/RejectInvalidAgentBearerMiddlewareTests.cs Adjusts auth middleware tests for session-scoped data context joining.
tests/LlamaShears.UnitTests/Api/Authentication/DefaultAgentClaimsProjectorTests.cs Updates claims projector tests to assert session-canonical NameIdentifier.
tests/LlamaShears.UnitTests/Api/Authentication/AgentBearerAuthenticationTests.cs Updates bearer auth tests to parse/validate SessionId from claims.
tests/LlamaShears.UnitTests/Agent/Core/TestAgentConfigs.cs Adds helpers to build default sessions and session-scoped data contexts.
tests/LlamaShears.UnitTests/Agent/Core/Persistence/JsonLineContextStoreTests.cs Updates persistence tests for new session-based storage layout.
tests/LlamaShears.UnitTests/Agent/Core/FakeDataContextScope.cs Changes fake scope key from string to SessionId.
tests/LlamaShears.UnitTests/Agent/Core/FakeContextStore.cs Updates fake context store to key by SessionId.
tests/LlamaShears.UnitTests/Agent/Core/ContextCompactorTests.cs Updates compactor test stubs to use SessionId in store calls.
tests/LlamaShears.UnitTests/Agent/Core/CapturingTurnSubscriber.cs Subscribes to session-scoped turn events and opts into preserved execution context.
tests/LlamaShears.UnitTests/Agent/Core/AgentTurnFlowTests.cs Refactors turn-flow tests to publish/subscribe by session and new ChannelMessage shape.
tests/LlamaShears.UnitTests/Agent/Core/AgentTokenStoreTests.cs Updates token store tests to construct AgentInfo with a SessionId.
tests/LlamaShears.UnitTests/Agent/Core/AgentLoopTests.cs Refactors loop tests for session-targeted message routing.
tests/LlamaShears.UnitTests/Agent/Core/AgentLockTests.cs Uses session-scoped data context keys for locking tests.
tests/LlamaShears.UnitTests/Agent/Core/AgentInterruptTests.cs Updates interrupt tests to target session ids in command events.
tests/LlamaShears.UnitTests/Agent/Core/AgentInterruptGracefulTests.cs Updates graceful interrupt tests for session-based routing and scoping.
tests/LlamaShears.UnitTests/Agent/Core/AgentEventPublishingTests.cs Updates event publishing expectations to carry session ids; adapts IEventBus signature in test harness.
tests/LlamaShears.IntegrationTests/ContextPersistenceTests.cs Updates integration tests to resolve default sessions and drive UI/chat by session.
tests/LlamaShears.IntegrationTests.Fixtures/Hosting/IsolatedAppFactory.cs Makes lifecycle waiting robust to session-id event routing by parsing envelope ids.
src/public/LlamaShears.Core.Abstractions/Events/IEventBus.cs Adds preserveSubscriberExecutionContext parameter to Subscribe.
src/public/LlamaShears.Core.Abstractions/Events/Channel/ChannelMessage.cs Changes ChannelMessage payload shape to remove agent targeting and include ChannelId.
src/public/LlamaShears.Core.Abstractions/Context/IAgentContextProvider.cs Changes snapshot creation API to accept SessionId.
src/public/LlamaShears.Core.Abstractions/Common/IDataContextScope.cs Changes scope key type to SessionId.
src/public/LlamaShears.Core.Abstractions/Common/IDataContextFactory.cs Changes scope APIs to key by SessionId.
src/public/LlamaShears.Core.Abstractions/Commands/SlashCommandContext.cs Changes slash command context to carry SessionId.
src/public/LlamaShears.Core.Abstractions/Agent/Persistence/IContextStore.cs Refactors persistence API to take SessionId and updates storage remarks.
src/public/LlamaShears.Core.Abstractions/Agent/Persistence/IAgentContext.cs Removes agent/session identifiers from the interface surface.
src/public/LlamaShears.Core.Abstractions/Agent/Persistence/ArchiveId.cs Refactors ArchiveId to (SessionId, UnixMillis).
src/public/LlamaShears.Core.Abstractions/Agent/IAgentInstanceRepository.cs Adds TryGetDefaultSession for UI/auth lookup of root sessions.
src/public/LlamaShears.Core.Abstractions/Agent/AgentInfo.cs Changes catalog entry to represent a session; adds AgentId convenience accessor.
src/LlamaShears.Core/Tools/ModelContextProtocol/ToolResponseClamp.cs Removes tool output clamping helper.
src/LlamaShears.Core/Tools/ModelContextProtocol/ModelContextProtocolToolCallDispatcher.cs Stops applying output clamping to tool results.
src/LlamaShears.Core/Tools/ModelContextProtocol/LoopbackBearerHandler.cs Issues bearer tokens for session-canonical identities and logs session ids.
src/LlamaShears.Core/Persistence/JsonLineContextStore.cs Implements new session-based folder/file resolution for persistence.
src/LlamaShears.Core/Persistence/AgentTurnContextPersister.cs Refactors turn persister to rely on ambient session scope.
src/LlamaShears.Core/Persistence/AgentContext.cs Stores SessionId in agent context implementation while keeping compat accessors.
src/LlamaShears.Core/InferenceRunner.cs Publishes agent/fragment/tool events keyed by session id; tool dispatch uses session id.
src/LlamaShears.Core/DataContext/DataContextScope.cs Changes scope key to SessionId.
src/LlamaShears.Core/DataContext/DataContextFactory.cs Rekeys scope registry to SessionId.
src/LlamaShears.Core/ContextCompactor.cs Publishes compaction lifecycle and performs clear/open using session id.
src/LlamaShears.Core/Context/AgentContextProvider.cs Builds snapshots using SessionId.
src/LlamaShears.Core/CompactionAgentService.cs Subscribes to compaction events by session and preserves execution context for handlers.
src/LlamaShears.Core/AgentIterationRunner.cs Publishes turns by session id and requests context snapshots by session.
src/LlamaShears.Core/AgentInstanceRepository.cs Tracks and removes default session ids per agent.
src/LlamaShears.Core/AgentFactory.cs Creates data contexts keyed by SessionId when creating agent scopes.
src/LlamaShears.Core/Agent.cs Subscribes/publishes lifecycle/message/interrupt events by session and preserves execution context.
src/LlamaShears.Core.Eventing/EventHandlerWrapperOptions.cs Adds captured execution context to wrapper options.
src/LlamaShears.Core.Eventing/EventHandlerWrapper.cs Restores captured execution context around handler invocation.
src/LlamaShears.Core.Eventing/EventBus.cs Captures execution context for subscribers that opt in via preserveSubscriberExecutionContext.
src/LlamaShears.Api/WebApplicationBuilderExtensions.cs Increases SignalR MaximumReceiveMessageSize to 32MB.
src/LlamaShears.Api/Web/AgentDirectory.cs Changes web directory operations to be session-scoped.
src/LlamaShears.Api/Tools/ModelContextProtocol/Filesystem/AgentWorkspaceLocator.cs Parses session canonical from claims to resolve agent workspace.
src/LlamaShears.Api/Authentication/RejectInvalidAgentBearerMiddleware.cs Joins session data scope based on session-canonical claim.
src/LlamaShears.Api/Authentication/DefaultAgentClaimsProjector.cs Emits NameIdentifier claim carrying session canonical.
src/LlamaShears.Api.Web/Services/SlashCommands/InterruptCommand.cs Executes interrupt against session-scoped directory API.
src/LlamaShears.Api.Web/Services/SlashCommands/CompactCommand.cs Executes compaction request against session-scoped directory API.
src/LlamaShears.Api.Web/Services/SlashCommands/ClearCommand.cs Executes clear against session-scoped directory API.
src/LlamaShears.Api.Web/Services/SlashCommands/ArchiveCommand.cs Executes archive/clear against session-scoped directory API.
src/LlamaShears.Api.Web/Services/IChatSession.cs Updates chat session abstraction to track SelectedSession.
src/LlamaShears.Api.Web/Services/IAgentDirectory.cs Changes directory interface to session-scoped operations.
src/LlamaShears.Api.Web/Services/ChatSession.cs Refactors chat session to select sessions, route by session events, and use new ChannelMessage payload.
src/LlamaShears.Api.Web/Pages/Chat.razor Resolves default session via repository for deep-linking by agent id.
src/LlamaShears.Api.Web/js/scripts/composer-paste.js Improves image paste handling by pre-scanning clipboard items.
src/LlamaShears.Api.Web/Components/Chat/ChatHeader.razor Selects default session when choosing an agent and adjusts navigation behavior.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/IAgentInstanceRepository.md Documents TryGetDefaultSession.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Events/Channel/index.md Updates channel events docs for session-targeted messages.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Events/Channel/ChannelMessage.md Updates ChannelMessage docs to match new payload.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Context/index.md Updates context docs to describe session-bearing snapshot API.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Context/IAgentContextProvider.md Documents CreateAgentContextAsync(SessionId, ...).
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Common/IDataContextScope.md Updates docs for scope key/session semantics.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Common/IDataContextFactory.md Updates docs for session-keyed scope APIs.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Commands/SlashCommandContext.md Updates docs for session-scoped slash commands.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Commands/index.md Updates command docs wording to “session” rather than “agent”.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/Persistence/index.md Updates persistence docs for session-based archive ids/layout.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/Persistence/IContextStore.md Updates store docs for SessionId-keyed API.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/Persistence/IAgentContext.md Updates docs to reflect removed AgentId/SessionId properties from interface.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/Persistence/ArchiveId.md Updates docs for (SessionId, UnixMillis) archive identity.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/index.md Updates agent docs wording to reflect session-based AgentInfo.
docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/AgentInfo.md Updates AgentInfo docs for session-based identity.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull request overview This PR refactors the codebase to use `SessionId` as the canonical identifier end-to-end (persistence, data scopes, auth claims, event routing, slash commands, and UI state), and includes web UI fixes for image paste and larger SignalR payloads. **Changes:** - Replace agent/session tuple routing with `SessionId` across persistence (`IContextStore`, `ArchiveId`), data context (`IDataContextScope`/`Factory`), and agent snapshot APIs (`IAgentContextProvider`, `AgentInfo`). - Update eventing to publish/subscribe by session-canonical ids and add `preserveSubscriberExecutionContext` to `IEventBus.Subscribe`. - Web/UI updates: session selection in chat UI, improved clipboard paste handling, and increased SignalR message size limit. ### Reviewed changes Copilot reviewed 79 out of 79 changed files in this pull request and generated 6 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | tests/LlamaShears.UnitTests/Context/AgentContextProviderTests.cs | Updates unit tests to construct contexts via `SessionId`. | | tests/LlamaShears.UnitTests/Api/Authentication/RejectInvalidAgentBearerMiddlewareTests.cs | Adjusts auth middleware tests for session-scoped data context joining. | | tests/LlamaShears.UnitTests/Api/Authentication/DefaultAgentClaimsProjectorTests.cs | Updates claims projector tests to assert session-canonical `NameIdentifier`. | | tests/LlamaShears.UnitTests/Api/Authentication/AgentBearerAuthenticationTests.cs | Updates bearer auth tests to parse/validate `SessionId` from claims. | | tests/LlamaShears.UnitTests/Agent/Core/TestAgentConfigs.cs | Adds helpers to build default sessions and session-scoped data contexts. | | tests/LlamaShears.UnitTests/Agent/Core/Persistence/JsonLineContextStoreTests.cs | Updates persistence tests for new session-based storage layout. | | tests/LlamaShears.UnitTests/Agent/Core/FakeDataContextScope.cs | Changes fake scope key from string to `SessionId`. | | tests/LlamaShears.UnitTests/Agent/Core/FakeContextStore.cs | Updates fake context store to key by `SessionId`. | | tests/LlamaShears.UnitTests/Agent/Core/ContextCompactorTests.cs | Updates compactor test stubs to use `SessionId` in store calls. | | tests/LlamaShears.UnitTests/Agent/Core/CapturingTurnSubscriber.cs | Subscribes to session-scoped turn events and opts into preserved execution context. | | tests/LlamaShears.UnitTests/Agent/Core/AgentTurnFlowTests.cs | Refactors turn-flow tests to publish/subscribe by session and new `ChannelMessage` shape. | | tests/LlamaShears.UnitTests/Agent/Core/AgentTokenStoreTests.cs | Updates token store tests to construct `AgentInfo` with a `SessionId`. | | tests/LlamaShears.UnitTests/Agent/Core/AgentLoopTests.cs | Refactors loop tests for session-targeted message routing. | | tests/LlamaShears.UnitTests/Agent/Core/AgentLockTests.cs | Uses session-scoped data context keys for locking tests. | | tests/LlamaShears.UnitTests/Agent/Core/AgentInterruptTests.cs | Updates interrupt tests to target session ids in command events. | | tests/LlamaShears.UnitTests/Agent/Core/AgentInterruptGracefulTests.cs | Updates graceful interrupt tests for session-based routing and scoping. | | tests/LlamaShears.UnitTests/Agent/Core/AgentEventPublishingTests.cs | Updates event publishing expectations to carry session ids; adapts IEventBus signature in test harness. | | tests/LlamaShears.IntegrationTests/ContextPersistenceTests.cs | Updates integration tests to resolve default sessions and drive UI/chat by session. | | tests/LlamaShears.IntegrationTests.Fixtures/Hosting/IsolatedAppFactory.cs | Makes lifecycle waiting robust to session-id event routing by parsing envelope ids. | | src/public/LlamaShears.Core.Abstractions/Events/IEventBus.cs | Adds `preserveSubscriberExecutionContext` parameter to `Subscribe`. | | src/public/LlamaShears.Core.Abstractions/Events/Channel/ChannelMessage.cs | Changes `ChannelMessage` payload shape to remove agent targeting and include `ChannelId`. | | src/public/LlamaShears.Core.Abstractions/Context/IAgentContextProvider.cs | Changes snapshot creation API to accept `SessionId`. | | src/public/LlamaShears.Core.Abstractions/Common/IDataContextScope.cs | Changes scope key type to `SessionId`. | | src/public/LlamaShears.Core.Abstractions/Common/IDataContextFactory.cs | Changes scope APIs to key by `SessionId`. | | src/public/LlamaShears.Core.Abstractions/Commands/SlashCommandContext.cs | Changes slash command context to carry `SessionId`. | | src/public/LlamaShears.Core.Abstractions/Agent/Persistence/IContextStore.cs | Refactors persistence API to take `SessionId` and updates storage remarks. | | src/public/LlamaShears.Core.Abstractions/Agent/Persistence/IAgentContext.cs | Removes agent/session identifiers from the interface surface. | | src/public/LlamaShears.Core.Abstractions/Agent/Persistence/ArchiveId.cs | Refactors `ArchiveId` to `(SessionId, UnixMillis)`. | | src/public/LlamaShears.Core.Abstractions/Agent/IAgentInstanceRepository.cs | Adds `TryGetDefaultSession` for UI/auth lookup of root sessions. | | src/public/LlamaShears.Core.Abstractions/Agent/AgentInfo.cs | Changes catalog entry to represent a session; adds `AgentId` convenience accessor. | | src/LlamaShears.Core/Tools/ModelContextProtocol/ToolResponseClamp.cs | Removes tool output clamping helper. | | src/LlamaShears.Core/Tools/ModelContextProtocol/ModelContextProtocolToolCallDispatcher.cs | Stops applying output clamping to tool results. | | src/LlamaShears.Core/Tools/ModelContextProtocol/LoopbackBearerHandler.cs | Issues bearer tokens for session-canonical identities and logs session ids. | | src/LlamaShears.Core/Persistence/JsonLineContextStore.cs | Implements new session-based folder/file resolution for persistence. | | src/LlamaShears.Core/Persistence/AgentTurnContextPersister.cs | Refactors turn persister to rely on ambient session scope. | | src/LlamaShears.Core/Persistence/AgentContext.cs | Stores `SessionId` in agent context implementation while keeping compat accessors. | | src/LlamaShears.Core/InferenceRunner.cs | Publishes agent/fragment/tool events keyed by session id; tool dispatch uses session id. | | src/LlamaShears.Core/DataContext/DataContextScope.cs | Changes scope key to `SessionId`. | | src/LlamaShears.Core/DataContext/DataContextFactory.cs | Rekeys scope registry to `SessionId`. | | src/LlamaShears.Core/ContextCompactor.cs | Publishes compaction lifecycle and performs clear/open using session id. | | src/LlamaShears.Core/Context/AgentContextProvider.cs | Builds snapshots using `SessionId`. | | src/LlamaShears.Core/CompactionAgentService.cs | Subscribes to compaction events by session and preserves execution context for handlers. | | src/LlamaShears.Core/AgentIterationRunner.cs | Publishes turns by session id and requests context snapshots by session. | | src/LlamaShears.Core/AgentInstanceRepository.cs | Tracks and removes default session ids per agent. | | src/LlamaShears.Core/AgentFactory.cs | Creates data contexts keyed by `SessionId` when creating agent scopes. | | src/LlamaShears.Core/Agent.cs | Subscribes/publishes lifecycle/message/interrupt events by session and preserves execution context. | | src/LlamaShears.Core.Eventing/EventHandlerWrapperOptions.cs | Adds captured execution context to wrapper options. | | src/LlamaShears.Core.Eventing/EventHandlerWrapper.cs | Restores captured execution context around handler invocation. | | src/LlamaShears.Core.Eventing/EventBus.cs | Captures execution context for subscribers that opt in via `preserveSubscriberExecutionContext`. | | src/LlamaShears.Api/WebApplicationBuilderExtensions.cs | Increases SignalR `MaximumReceiveMessageSize` to 32MB. | | src/LlamaShears.Api/Web/AgentDirectory.cs | Changes web directory operations to be session-scoped. | | src/LlamaShears.Api/Tools/ModelContextProtocol/Filesystem/AgentWorkspaceLocator.cs | Parses session canonical from claims to resolve agent workspace. | | src/LlamaShears.Api/Authentication/RejectInvalidAgentBearerMiddleware.cs | Joins session data scope based on session-canonical claim. | | src/LlamaShears.Api/Authentication/DefaultAgentClaimsProjector.cs | Emits `NameIdentifier` claim carrying session canonical. | | src/LlamaShears.Api.Web/Services/SlashCommands/InterruptCommand.cs | Executes interrupt against session-scoped directory API. | | src/LlamaShears.Api.Web/Services/SlashCommands/CompactCommand.cs | Executes compaction request against session-scoped directory API. | | src/LlamaShears.Api.Web/Services/SlashCommands/ClearCommand.cs | Executes clear against session-scoped directory API. | | src/LlamaShears.Api.Web/Services/SlashCommands/ArchiveCommand.cs | Executes archive/clear against session-scoped directory API. | | src/LlamaShears.Api.Web/Services/IChatSession.cs | Updates chat session abstraction to track `SelectedSession`. | | src/LlamaShears.Api.Web/Services/IAgentDirectory.cs | Changes directory interface to session-scoped operations. | | src/LlamaShears.Api.Web/Services/ChatSession.cs | Refactors chat session to select sessions, route by session events, and use new `ChannelMessage` payload. | | src/LlamaShears.Api.Web/Pages/Chat.razor | Resolves default session via repository for deep-linking by agent id. | | src/LlamaShears.Api.Web/js/scripts/composer-paste.js | Improves image paste handling by pre-scanning clipboard items. | | src/LlamaShears.Api.Web/Components/Chat/ChatHeader.razor | Selects default session when choosing an agent and adjusts navigation behavior. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/IAgentInstanceRepository.md | Documents `TryGetDefaultSession`. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Events/Channel/index.md | Updates channel events docs for session-targeted messages. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Events/Channel/ChannelMessage.md | Updates `ChannelMessage` docs to match new payload. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Context/index.md | Updates context docs to describe session-bearing snapshot API. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Context/IAgentContextProvider.md | Documents `CreateAgentContextAsync(SessionId, ...)`. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Common/IDataContextScope.md | Updates docs for scope key/session semantics. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Common/IDataContextFactory.md | Updates docs for session-keyed scope APIs. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Commands/SlashCommandContext.md | Updates docs for session-scoped slash commands. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Commands/index.md | Updates command docs wording to “session” rather than “agent”. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/Persistence/index.md | Updates persistence docs for session-based archive ids/layout. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/Persistence/IContextStore.md | Updates store docs for `SessionId`-keyed API. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/Persistence/IAgentContext.md | Updates docs to reflect removed AgentId/SessionId properties from interface. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/Persistence/ArchiveId.md | Updates docs for `(SessionId, UnixMillis)` archive identity. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/index.md | Updates agent docs wording to reflect session-based `AgentInfo`. | | docs/api/LlamaShears.Core.Abstractions/LlamaShears/Core/Abstractions/Agent/AgentInfo.md | Updates `AgentInfo` docs for session-based identity. | </details> --- 💡 <a href="/jasoncouture/llama-shears/new/main?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-05-20 00:13:47 -04:00

When the bearer token contains a valid SessionId but the corresponding data scope can’t be joined, the middleware returns 500. This scenario can occur with a stale token for an agent/session that isn’t running, which is more appropriately treated as an auth failure (401/403) rather than an internal error. Consider returning 403 (or 401) and optionally logging the condition instead of 500.

When the bearer token contains a valid SessionId but the corresponding data scope can’t be joined, the middleware returns 500. This scenario can occur with a stale token for an agent/session that isn’t running, which is more appropriately treated as an auth failure (401/403) rather than an internal error. Consider returning 403 (or 401) and optionally logging the condition instead of 500.
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-05-20 00:13:46 -04:00

AgentTurnContextPersister currently relies on IDataContextFactory.Current to discover the session to persist, but this handler is registered as an activated singleton (via AddEventHandler) and will typically run with no ambient data scope. As a result, turns will be dropped on the floor (session == null => return) and persisted context won’t update. Consider deriving the target SessionId from the event envelope (e.g., parse envelope.Type.Id as a SessionId) rather than relying on ambient scope, and then OpenAsync/AppendAsync against that session.

AgentTurnContextPersister currently relies on IDataContextFactory.Current to discover the session to persist, but this handler is registered as an activated singleton (via AddEventHandler) and will typically run with no ambient data scope. As a result, turns will be dropped on the floor (session == null => return) and persisted context won’t update. Consider deriving the target SessionId from the event envelope (e.g., parse envelope.Type.Id as a SessionId) rather than relying on ambient scope, and then OpenAsync/AppendAsync against that session.
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-05-20 00:13:46 -04:00

Non-default session persistence uses Path.Combine(session.AgentId, session.Name) as the folder, but does not include session.Id. This means multiple sessions with the same (AgentId, Name) will share the same archive namespace: ClearAsync archives to ".json" and ListArchivesAsync will return archives created by other sessions with the same Name. Consider scoping the folder (or archive filenames) by session.Id so archives/current data cannot collide or bleed across sessions.

Non-default session persistence uses Path.Combine(session.AgentId, session.Name) as the folder, but does not include session.Id. This means multiple sessions with the same (AgentId, Name) will share the same archive namespace: ClearAsync archives to "<unixMillis>.json" and ListArchivesAsync will return archives created by other sessions with the same Name. Consider scoping the folder (or archive filenames) by session.Id so archives/current data cannot collide or bleed across sessions.
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-05-20 00:13:46 -04:00

ResolveFolder uses session.Name as a directory name. SessionId.Name explicitly allows ':' (and other characters) for canonical round-tripping, which will produce invalid paths on Windows (':' is not permitted in directory names). Consider encoding/sanitizing Name for filesystem use, or avoiding Name in the directory path and using only session.Id (or another filesystem-safe representation).

ResolveFolder uses session.Name as a directory name. SessionId.Name explicitly allows ':' (and other characters) for canonical round-tripping, which will produce invalid paths on Windows (':' is not permitted in directory names). Consider encoding/sanitizing Name for filesystem use, or avoiding Name in the directory path and using only session.Id (or another filesystem-safe representation).
@ -65,12 +65,11 @@ public sealed partial class ModelContextProtocolToolCallDispatcher : IToolCallDi
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-05-20 00:13:47 -04:00

ToolResponseClamp was removed, so tool results are now returned/published unbounded. A single large MCP tool response can inflate event payloads, UI memory usage, and model prompt size, potentially causing failures (e.g., exceeding context window or transport limits). Consider reinstating output clamping (or adding an alternative size/line limit) before returning/publishing the result content.

ToolResponseClamp was removed, so tool results are now returned/published unbounded. A single large MCP tool response can inflate event payloads, UI memory usage, and model prompt size, potentially causing failures (e.g., exceeding context window or transport limits). Consider reinstating output clamping (or adding an alternative size/line limit) before returning/publishing the result content.
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-05-20 00:13:47 -04:00

The XML doc says ChannelMessage is published with the channel id in the event type Id segment, but the updated routing publishes/subscribes Channel.Message by session id and carries the channel as ChannelId in the payload. This comment (and the generated docs) should be updated to match the new routing semantics. Also, the using for Agent.Sessions appears unused in this file after the signature change.

The XML doc says ChannelMessage is published with the channel id in the event type Id segment, but the updated routing publishes/subscribes Channel.Message by session id and carries the channel as ChannelId in the payload. This comment (and the generated docs) should be updated to match the new routing semantics. Also, the using for Agent.Sessions appears unused in this file after the signature change.
Sign in to join this conversation.
No description provided.