feat(agent): let the agent list and update scheduled posts#1689
Closed
giladresisi wants to merge 1 commit into
Closed
feat(agent): let the agent list and update scheduled posts#1689giladresisi wants to merge 1 commit into
giladresisi wants to merge 1 commit into
Conversation
Adds two agent/MCP tools so an agent (web-app chat or an external MCP client) can change already-scheduled posts, not just create them: - postsListTool: lists the user's upcoming (not-yet-published) posts - both drafts and scheduled posts whose publish time is still in the future. By default returns all of them in one call, so "list all my unpublished posts" needs no arguments. Past posts (including old forgotten drafts) are never listed. Optional "state" narrows to only future drafts or only future scheduled. Filterable by platform/channel, paginated, each item carries its state (draft/scheduled) and current provider settings so the agent can pick what to change. Backed by a new getAgentPostsList repository + service method. - updatePostTool: updates one post by its stable id - settings are merged (only the passed keys change), date and content optional. Refuses published/past posts, runs the same server-side validation as the dashboard, preserves the root post id (so the Temporal workflow identity is kept) and only restarts the workflow when the publish date actually changed on a queued post. Agent prompt guidance: changes to existing posts are always applied directly with updatePostTool; the agent must not open the "populated modal" (manualPosting) for an existing post since that only creates a new post (would duplicate). No delete tool exists (deletion is destructive); the prompt tells the agent never to offer deletion and, if asked, to defer it to the user in the Postiz app. External MCP agents can't delete either (no tool), so they infer it from the toolset. keepGroup: out-of-band updates keep the post's group id stable instead of rotating it (removed comments are swept by id instead). The group rotation on every edit would otherwise invalidate an open calendar that still holds the old group. The dashboard keeps its rotate-and-sweep behavior unchanged. Guard (defense-in-depth for the same stale-group race, which also predates this via multi-device dashboard edits/deletes): - getPostsByGroup throws 404 instead of a 500 when the group has no posts. - calendar editPost detects an empty group, shows a toast and reloads the calendar instead of crashing on posts[0]. Tested end-to-end, both the internal agent and an external MCP client: - Internal agent (web-app chat): "list my posts" returns the upcoming posts; asking to reschedule or change a setting is applied directly via updatePostTool - no delete offered, and no populated modal opened for an existing post. - postsListTool: default (all upcoming), platform and integrationId filters, draft/scheduled states, and pagination across pages (verified page/total/hasMore and no overlap with the page size temporarily lowered). - updatePostTool happy paths: a settings-only update leaves the Temporal workflow untouched (verified against the Temporal run list); a real date change restarts it (TERMINATE_EXISTING, exactly one new run); the post id and group stay stable with no duplicate; content grow/shrink and bulk multi-post updates apply correctly. - updatePostTool guards, each confirmed to reject and leave the post unchanged: a published post, a comment's id (must pass the root post), a non-existent id, and content that fails validation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Contribution-checker quality warning Heuristics that flagged:
If this is a genuine contribution, please add detail to your PR description and tighten the diff scope before reviewers look at it. |
|
| Status | Scan Engine | Total (0) | ||||
|---|---|---|---|---|---|---|
| Open Source Security | 0 | 0 | 0 | 0 | See details | |
| Licenses | 0 | 0 | 0 | 0 | See details | |
| ✅ | Code Security | 0 | 0 | 0 | 0 | 0 issues |
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.
Contributor
|
There should be only a settings update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two agent/MCP tools so an agent (web-app chat or an external MCP client) can change already-scheduled posts, not just create them:
postsListTool— lists the user's upcoming (not-yet-published) posts: all drafts + scheduled posts still in the future. Default returns everything in one call (so "list all my unpublished posts" needs no args); past posts are never listed. Optionalstatenarrows to drafts or scheduled; filterable by platform/channel; paginated; each item carries itsstate(draft/scheduled) and current provider settings.updatePostTool— updates one post by its stable id: settings are merged (only passed keys change), date and content optional. Refuses published/past posts, runs the same server-side validation as the dashboard, preserves the root post id (keeps the Temporal workflow identity), and only restarts the workflow when the publish date actually changed.Plus: prompt guidance (apply changes to existing posts via the tool, never the create-modal; never offer deletion — there is no delete tool),
keepGroupso out-of-band updates don't invalidate an open calendar, and a defense-in-depth guard turning a stale-group 500 into a 404 + calendar self-heal.Testing
Exercised end-to-end via both the internal agent and an external MCP client:
updatePostTool; no delete offered; no create-modal opened for existing posts.postsListTool: default (all upcoming), platform + integrationId filters, draft/scheduled states, and pagination across pages (page/total/hasMore, no overlap).updatePostToolhappy paths: settings-only update leaves the Temporal workflow untouched (checked the run list); a real date change restarts it (TERMINATE_EXISTING, one new run); post id + group stable, no duplicate; content grow/shrink and bulk multi-post.updatePostToolguards (each rejected, post left unchanged): published post, a comment's id, a non-existent id, content that fails validation.🤖 Generated with Claude Code