Skip to content

fix agent delete#466

Merged
iceljc merged 1 commit into
SciSharp:mainfrom
iceljc:main
Jun 23, 2026
Merged

fix agent delete#466
iceljc merged 1 commit into
SciSharp:mainfrom
iceljc:main

Conversation

@iceljc

@iceljc iceljc commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@iceljc iceljc merged commit 65baeaf into SciSharp:main Jun 23, 2026
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add delete options payload to agent deletion request
🐞 Bug fix ✨ Enhancement 🕐 10-20 Minutes

Grey Divider

Description

• Define a typed delete-options model for agent deletions.
• Extend deleteAgent() to accept options and send them in the DELETE request body.
• Enable selective cascading deletes (roles/users/code scripts) via server-side options.
Diagram

graph TD
  UI["Caller (UI/SDK)"] --> SVC["agent-service.deleteAgent"] --> AX["axios.delete"] --> API["Agent Detail API"]
  SVC --> OPT["AgentDeleteOptions"]

  subgraph Legend
    direction LR
    _caller["Caller"] ~~~ _svc["Service"] ~~~ _http["HTTP client"] ~~~ _api["API endpoint"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use query parameters for delete options
  • ➕ Avoids relying on DELETE request bodies (some proxies/servers mishandle them).
  • ➕ Easier to inspect in logs and network tooling.
  • ➖ Harder to express structured payloads (e.g., lists like to_delete_code_scripts).
  • ➖ More awkward API surface as options grow.
2. Create a dedicated POST delete-action endpoint
  • ➕ Avoids any ambiguity about bodies on DELETE.
  • ➕ Can evolve into a richer 'delete job' or async delete workflow.
  • ➖ Requires API design change and potentially breaks REST semantics expectations.
  • ➖ More backend routing/permission surface area.

Recommendation: The current approach (passing { data: { options } } to axios.delete) is reasonable if the backend explicitly supports a DELETE body and your infrastructure reliably forwards it. Confirm the server contract and any intermediary (API gateway/proxy) behavior; if DELETE bodies are problematic in your environment, prefer a dedicated POST action endpoint.

Files changed (2) +11 / -3

Enhancement (1) +8 / -1
agentTypes.jsAdd AgentDeleteOptions typedef for configurable deletions +8/-1

Add AgentDeleteOptions typedef for configurable deletions

• Introduces 'AgentDeleteOptions' to describe optional cascading delete behavior (role agents, user agents, and code scripts). This improves type clarity/consumer guidance for delete calls.

src/lib/helpers/types/agentTypes.js

Bug fix (1) +3 / -2
agent-service.jsAllow deleteAgent() to send optional delete options in request body +3/-2

Allow deleteAgent() to send optional delete options in request body

• Extends 'deleteAgent' to accept an optional 'AgentDeleteOptions' parameter and forwards it in the axios DELETE config body ('data'). This enables more precise server-side deletion behavior instead of unconditional deletes.

src/lib/services/agent-service.js

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Nested delete options body 🐞 Bug ≡ Correctness
Description
deleteAgent() sends the provided delete flags as a nested body { options: AgentDeleteOptions },
not as the AgentDeleteOptions object itself, which is inconsistent with other DELETE requests in
this repo that place request fields directly under data. If the backend expects top-level
delete_role_agents/delete_user_agents fields, the flags will be ignored and deletion behavior
will be wrong.
Code

src/lib/services/agent-service.js[R71-75]

+ * @param {import('$agentTypes').AgentDeleteOptions | null} options
 */
-export async function deleteAgent(agentId) {
+export async function deleteAgent(agentId, options = null) {
    let url = endpoints.agentDetailUrl.replace("{id}", agentId);
-    await axios.delete(url);
+    await axios.delete(url, { data: options ? { options } : {} });
Evidence
The agent delete now wraps the payload under an options key, while other DELETE services in the
repo pass request fields directly as data properties, indicating a likely contract mismatch risk.

src/lib/services/agent-service.js[68-76]
src/lib/services/knowledge-base-service.js[164-176]
src/lib/services/conversation-service.js[192-207]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`deleteAgent()` currently wraps the passed `AgentDeleteOptions` object under an extra `options` key in the DELETE request body (`{ data: { options } }`). This makes the wire format differ from what many DELETE endpoints in this repo do (placing fields directly under `data`) and can easily mismatch the backend contract.

### Issue Context
This PR introduces `AgentDeleteOptions` and threads it into `deleteAgent()`. Other DELETE calls (e.g., knowledge-base deletes) send their request fields directly in `data` without an extra wrapper object.

### Fix Focus Areas
- src/lib/services/agent-service.js[73-76]

### Suggested fix
Pick one approach and make types/docs match the actual wire format:
1) If backend expects top-level fields: change to `await axios.delete(url, { data: options ?? {} });`
2) If backend expects `{ options: ... }`: keep the request body as-is, but update the JSDoc to reflect the real request shape (e.g., accept `optionsWrapper` of type `{ options: AgentDeleteOptions }`) and/or define an `AgentDeleteRequestModel` type with an `options` property.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Overly heavy delete scripts type 🐞 Bug ⚙ Maintainability
Description
AgentDeleteOptions.to_delete_code_scripts is typed as AgentCodeScriptViewModel[], whose required
fields include name, content, and script_type, making the delete-options type misleading for
callers and encouraging unnecessary inclusion of full script content. This degrades maintainability
for typed/JSDoc-checked callers and risks larger-than-needed delete payloads.
Code

src/lib/helpers/types/agentTypes.js[R148-153]

+/**
+ * @typedef {Object} AgentDeleteOptions
+ * @property {boolean?} [delete_role_agents]
+ * @property {boolean?} [delete_user_agents]
+ * @property {AgentCodeScriptViewModel[]?} [to_delete_code_scripts]
+ */
Evidence
The delete-options type explicitly references a view-model type that requires full script fields
(name, content, script_type), which is heavier than a delete reference and can mislead typed
callers.

src/lib/helpers/types/agentTypes.js[148-153]
src/lib/helpers/types/agentTypes.js[128-134]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`AgentDeleteOptions.to_delete_code_scripts` is currently typed as `AgentCodeScriptViewModel[]`, but `AgentCodeScriptViewModel` requires fields like `name`, `content`, and `script_type`. For a delete operation, callers typically only have/need an identifier (e.g., `uid`).

### Issue Context
This is a JSDoc/type-model issue that can mislead developers and (when using type checking) force unnecessary fields into delete requests.

### Fix Focus Areas
- src/lib/helpers/types/agentTypes.js[128-134]
- src/lib/helpers/types/agentTypes.js[148-153]

### Suggested fix
Introduce a dedicated minimal typedef for delete targets (e.g., `AgentCodeScriptDeleteRef` with just `uid`), and change `to_delete_code_scripts` to use that type (or make the `AgentCodeScriptViewModel` fields optional where appropriate for deletion).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment on lines +71 to +75
* @param {import('$agentTypes').AgentDeleteOptions | null} options
*/
export async function deleteAgent(agentId) {
export async function deleteAgent(agentId, options = null) {
let url = endpoints.agentDetailUrl.replace("{id}", agentId);
await axios.delete(url);
await axios.delete(url, { data: options ? { options } : {} });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Nested delete options body 🐞 Bug ≡ Correctness

deleteAgent() sends the provided delete flags as a nested body { options: AgentDeleteOptions },
not as the AgentDeleteOptions object itself, which is inconsistent with other DELETE requests in
this repo that place request fields directly under data. If the backend expects top-level
delete_role_agents/delete_user_agents fields, the flags will be ignored and deletion behavior
will be wrong.
Agent Prompt
### Issue description
`deleteAgent()` currently wraps the passed `AgentDeleteOptions` object under an extra `options` key in the DELETE request body (`{ data: { options } }`). This makes the wire format differ from what many DELETE endpoints in this repo do (placing fields directly under `data`) and can easily mismatch the backend contract.

### Issue Context
This PR introduces `AgentDeleteOptions` and threads it into `deleteAgent()`. Other DELETE calls (e.g., knowledge-base deletes) send their request fields directly in `data` without an extra wrapper object.

### Fix Focus Areas
- src/lib/services/agent-service.js[73-76]

### Suggested fix
Pick one approach and make types/docs match the actual wire format:
1) If backend expects top-level fields: change to `await axios.delete(url, { data: options ?? {} });`
2) If backend expects `{ options: ... }`: keep the request body as-is, but update the JSDoc to reflect the real request shape (e.g., accept `optionsWrapper` of type `{ options: AgentDeleteOptions }`) and/or define an `AgentDeleteRequestModel` type with an `options` property.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant