system-prompt tweaks, agent slimming, NO_RESPONSE handling, MCP tool-list cache #87
No reviewers
Labels
No labels
bug
commercial
documentation
duplicate
enhancement
feature
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jasoncouture/llama-shears!87
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "system-prompt-tweaks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
<message_metadata>user-prefix envelope, Memory Recall section,<server>__tool_nameconvention, parallel-tool limit bumped to 15.AsyncServiceScopeownership intoAgentManagerand resolvingILanguageModel/IContextCompactor/IInferenceRunnerper-turn from a scoped bundle. Tool discovery moved into the per-turn flow so live config edits land on the next turn.AgentStatedata-context record (ChannelId/EventId/CorrelationId) +IAgentStateTracker.SetState(...). Top-level data-context keys remain objects, never primitives. Per-field extension shortcuts mirrorAgentConfigExtensions.InferenceRunner:NO_RESPONSEsentinel handling. Streaming buffer detects prefix-of-sentinel, swallows the text, and reportsSuppressed = trueso the agent retry loop breaks cleanly instead of treating intentional silence as an empty response.ModelContextProtocolClient: tool-list cache (10 min success / 1 min failure), failures replay viaExceptionDispatchInfowrapped as the inner exception of a freshInvalidOperationExceptionto avoid stack-trace accumulation across replays.OperationCanceledExceptionnot cached.WorkspaceFile.Path(directory + trailing separator) soPath + Nameis absolute; workspace reads cached viaIFileParserCachewith a static parser.--no-local-configCLI flag andLLAMASHEARS_NO_LOCAL_CONFIG=trueenv var bypass~/.llama-shears/appsettings.jsonso integration tests don't pick up local config. DI now runs withValidateScopes = trueandValidateOnBuild = true.hljsthrough the bundle's module graph inhighlight-init.js. esbuild bundleshighlight.min.jsas CJS sovar hljsnever reacheswindow—!window.hljswas silently bailing and no<pre><code>was being highlighted.AgentState,WorkspaceFile.Path,IAgent.Test plan
dotnet buildclean (no warnings, no errors)dotnet test— 510/510 passclass="hljs language-…"and github-dark theme colors after page load🤖 Generated with Claude Code
Pull request overview
This PR refactors agent turn execution and prompt/context plumbing, adds agent-state metadata and intentional
NO_RESPONSEhandling, introduces MCP tool-list caching, and updates UI/script/docs support around those changes.Changes:
AgentState.NO_RESPONSEsuppression semantics.Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 10 comments.
Show a summary per file
Path.Suppressedresult flag.NO_RESPONSEdetection and suppression.Comments suppressed due to low confidence (2)
src/LlamaShears/content/templates/workspace/system/context/PROMPT.md:10
<runtime_metadata>envelope; escape the value before inserting it into<channel>.src/LlamaShears/content/templates/workspace/system/compaction/PROMPT.md:10
<channel>.💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -33,1 +34,4 @@options.Rules.Add(new ProtectedFile("USER.md", ProtectionMode.Delete, FileType.File, "agent root markdown"));options.Rules.Add(new ProtectedFile("SOUL.md", ProtectionMode.Delete, FileType.File, "agent root markdown"));options.Rules.Add(new ProtectedFile("TOOLS.md", ProtectionMode.Delete, FileType.File, "agent root markdown"));options.Rules.Add(new ProtectedFile(".gitignore", ProtectionMode.Delete | ProtectionMode.Write, FileType.File, "workspace .gitignore"));Replacing the root-level
*.mddelete rule with this allowlist drops delete protection forMEMORY.md, even though the seeded AGENTS.md still treatsMEMORY.mdas long-term workspace memory. That lets an MCP file-delete call remove the curated memory file; add it to the protected list or keep the broader root-markdown delete rule if the memory file should remain durable.@ -333,15 +280,11 @@ public sealed partial class AgentManager : IAgentManager, IHostStartupTask, IEvevar dataProviders = scope.ServiceProvider.GetScopedDataProviders();If any step after
CreateContext(config.Id)fails (for example resolving the scopedILanguageModelwhen the provider name is invalid), the catch disposes the DI scope but leaves the data context registered inDataContextFactory. Because the factory keeps a weak reference until GC, the next reconcile can fail with “A data context with key ... is already active” instead of retrying cleanly. Delete the context in the failure path once it has been created.This resolves and constructs an
ILanguageModelduring agent startup but then discards it; per-turn processing resolves another model from each turn scope. If a provider model owns resources or performs initialization, the startup instance is kept alive in the agent scope for the agent lifetime without ever being used. Validate the provider configuration without creating the model, or dispose/use this instance intentionally.The new
NO_RESPONSEsuppression path is not covered by the existing InferenceRunner tests. Please add tests for at least the exact sentinel and split streaming fragments so regressions do not accidentally persist or publish the sentinel as assistant text, and soSuppressedreliably stops the empty-response retry loop.@ -24,3 +25,4 @@}sb.Append("</message_metadata>\n");sb.Append(turn.Content);return sb.ToString();ChannelIdis written into the new XML envelope without XML escaping. If a channel id supplied by another publisher/plugin contains characters like<,&, or a closing tag, it can make the metadata malformed or inject additional metadata-looking content that the system prompt treats as authoritative. Escape this value before appending it to the envelope.@ -8,3 +6,1 @@- Current day of week: {{ day_of_week }}{{- if channel_id }}- Channel: {{ channel_id }}<current_datetime>{{ now | format_datetimeoffset 'yyyy-MM-ddTHH:mm:sszzz' }}</current_datetime>important_messageis inserted into the XML metadata as raw text. If it contains XML-sensitive characters or closing tags, the generated envelope becomes malformed or can inject metadata-looking content; escape it before rendering into<important>.This issue also appears on line 9 of the same file.
@ -8,3 +6,1 @@- Current day of week: {{ day_of_week }}{{- if channel_id }}- Channel: {{ channel_id }}<current_datetime>{{ now | format_datetimeoffset 'yyyy-MM-ddTHH:mm:sszzz' }}</current_datetime>important_messageis now emitted inside an XML element without escaping. A value containing<,&, or a closing tag can corrupt the runtime metadata envelope or inject metadata-looking text that the prompt treats as authoritative; escape it before rendering.This issue also appears on line 9 of the same file.
These values are now embedded as XML attributes/text but are rendered without XML escaping. Memory paths/summaries can come from user-authored files, so characters like
&,<, quotes, or closing tags can break the metadata envelope or inject metadata-looking directives. Escape XML-sensitive values before rendering them into<runtime_metadata>.@ -9,3 +9,3 @@/// </summary>public interface IAgent : IDisposablepublic interface IAgent : IAsyncDisposable, IDisposable{Removing LastActivity from the public IAgent interface is a breaking change for any package consumer implementing or calling this abstraction. If the property is no longer used internally, keep a compatible member (possibly obsolete) or coordinate this with an explicit breaking-version release.
This changes the public WorkspaceFile positional record constructor from (Name, Content) to (Name, Path, Content), which will break source and binary compatibility for consumers of the packable Core.Abstractions package. Consider preserving the old constructor/property shape (for example with an overload or additive property) or gating this with an explicit breaking-version change.