Skip to content

feat(agents): add reactivate_agent and admin_reactivate_agent - #533

Open
lesbass wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
lesbass:feat/reactivate-agent
Open

feat(agents): add reactivate_agent and admin_reactivate_agent#533
lesbass wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
lesbass:feat/reactivate-agent

Conversation

@lesbass

@lesbass lesbass commented Aug 5, 2026

Copy link
Copy Markdown

Add the missing counterpart to deactivate_agent / admin_deactivate_agent, allowing owners to reactivate their paused agents and admins to reactivate any agent.

Changes

  • reactivate_agent: sets active = true for an agent, gated to the agent's owner (mirrors deactivate_agent)
  • admin_reactivate_agent: sets active = true for any agent, gated to the contract admin (mirrors admin_deactivate_agent)

Both functions preserve the agent's score and payment history — only the active flag is toggled.

Tests added

  • test_reactivate_agent_succeeds_for_owner — owner can reactivate their deactivated agent
  • test_reactivate_agent_rejects_non_owner — non-owner call panics; agent stays inactive
  • test_admin_reactivate_agent_succeeds — admin can reactivate any agent
  • test_admin_reactivate_agent_requires_admin — non-admin call panics

Verification

Local test run blocked by missing native build toolchain (cc linker not available). All four new tests follow the exact structure and patterns of the existing deactivate_agent / admin_deactivate_agent tests. CI run will confirm.

Closes #313

Summary by CodeRabbit

  • New Features

    • Added owner-authorized agent reactivation.
    • Added administrator-authorized agent reactivation.
    • Reactivated agents now have their active status restored and retention period refreshed.
  • Bug Fixes

    • Added authorization checks to prevent unauthorized agent reactivation.

Add the missing counterpart to deactivate_agent / admin_deactivate_agent,
allowing owners to reactivate their paused agents and admins to
reactivate any agent. Functions mirror the existing deactivation
pattern exactly: owner check for reactivate_agent, admin gate for
admin_reactivate_agent.

Tests cover:
- Owner can reactivate their own agent
- Non-owners are rejected
- Admin can reactivate any agent
- Non-admins are rejected by admin variant

Closes Stellar-Ecosystem#313

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@lesbass
lesbass requested a review from ritik4ever as a code owner August 5, 2026 06:31
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ccb5fb98-4919-48be-858c-81e4b1a68be6

📥 Commits

Reviewing files that changed from the base of the PR and between 0546692 and f7c45d9.

📒 Files selected for processing (1)
  • contract/agents/src/lib.rs

📝 Walkthrough

Walkthrough

The agents contract now supports owner- and admin-authorized reactivation. Each method authenticates and authorizes the caller, marks the agent active, persists the record, and refreshes its TTL. Tests cover successful and rejected reactivation attempts.

Changes

Agent reactivation

Layer / File(s) Summary
Owner and admin reactivation methods
contract/agents/src/lib.rs
Adds reactivate_agent and admin_reactivate_agent with caller authentication, authorization checks, active-state updates, persistence, and TTL renewal. Tests cover authorized and unauthorized callers.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: ritik4ever, naninu123, aadviksinghdebug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the two reactivation methods added by the pull request.
Linked Issues check ✅ Passed The changes implement owner and admin reactivation, authorization checks, state persistence, TTL refresh, and related tests for issue #313.
Out of Scope Changes check ✅ Passed The changes remain within issue #313 and support agent reactivation and authorization requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Agents: no reactivate_agent counterpart to deactivate_agent

1 participant