Repository navigation
fix(status): agent status follows the agent's own key; Scout checks it live (D172) #2969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lilyshen0722
wants to merge
5
commits into
main
Choose a base branch
from
fix/d172-agent-status
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
caf2648
fix(status): agent status follows the agent's own key, and Scout chec…
lilyshen0722 6bee1e0
fix(status): Scout's status tool sees the asker's agents in every pod…
lilyshen0722 d7d9d4a
fix(status): Scout reports active as a recent check-in; ledger read f…
lilyshen0722 bef9c34
fix(status): Scout names idle with restart advice; one five-minute ac…
lilyshen0722 1d5bde6
fix(scout): a hosted agent's idle state is not a health verdict (D172)
lilyshen0722 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /** | ||
| * commonly_agent_status is how Scout answers "is my agent running?". On | ||
| * 2026-10-28 it missed a listener that was polling: the seat was installed in | ||
| * another pod, and its key lived in the credential ledger, not on the bot User | ||
| * (D172). Real Mongo, so the stores are the ones runtime auth writes. | ||
| */ | ||
| const { setupMongoDb, closeMongoDb } = require('../utils/testUtils'); | ||
|
|
||
| jest.mock('axios', () => ({ __esModule: true, default: { post: jest.fn() } })); | ||
| jest.mock('../../services/agentComputerBroker', () => ({ | ||
| agentComputerBroker: {}, | ||
| agentComputerEnabled: false, | ||
| })); | ||
|
|
||
| const mongoose = require('mongoose'); | ||
| const User = require('../../models/User'); | ||
| const AgentCredential = require('../../models/AgentCredential'); | ||
| const { AgentInstallation } = require('../../models/AgentRegistry'); | ||
| const { dispatchTool } = require('../../services/nativeRuntimeService'); | ||
|
|
||
| jest.setTimeout(60000); | ||
|
|
||
| describe('commonly_agent_status', () => { | ||
| const scoutPod = new mongoose.Types.ObjectId(); | ||
| const otherPod = new mongoose.Types.ObjectId(); | ||
| let owner; | ||
| let bot; | ||
|
|
||
| beforeAll(async () => { | ||
| await setupMongoDb(); | ||
| owner = await User.create({ username: 'status-owner', email: 'status-owner@test.com', password: 'password123' }); | ||
| bot = await User.create({ | ||
| username: 'claude-code-status-seat', email: 'status-seat@test.com', password: 'password123', isBot: true, | ||
| botMetadata: { agentName: 'claude-code', instanceId: 'status-seat' }, | ||
| }); | ||
| }); | ||
|
|
||
| afterAll(async () => closeMongoDb()); | ||
|
|
||
| beforeEach(async () => { | ||
| await AgentInstallation.deleteMany({ agentName: 'claude-code' }); | ||
| await AgentCredential.deleteMany({ agentUserId: bot._id }); | ||
| await AgentInstallation.create({ | ||
| agentName: 'claude-code', instanceId: 'status-seat', podId: otherPod, version: '1', installedBy: owner._id, | ||
| config: new Map([['runtime', { runtimeType: 'wrapper' }]]), | ||
| }); | ||
| }); | ||
|
|
||
| const ask = (requesterId) => dispatchTool('commonly_agent_status', {}, { | ||
| podId: String(scoutPod), agentName: 'scout', instanceId: 'default', displayName: 'Scout', | ||
| installationConfig: {}, runId: 'run-status', computerRequesterId: requesterId, | ||
| }); | ||
|
|
||
| it('reports the asker\'s agent from another pod, live from its ledger key', async () => { | ||
| await AgentCredential.create({ | ||
| tokenHash: 'status-ledger-hash', kind: 'runtime', ownerUserId: owner._id, agentUserId: bot._id, | ||
| lastUsedAt: new Date(Date.now() - 5000), | ||
| }); | ||
| const result = await ask(String(owner._id)); | ||
| expect(result.content.agents).toEqual([expect.objectContaining({ | ||
| agentName: 'claude-code', state: 'active', inThisPod: false, | ||
| })]); | ||
| }); | ||
|
|
||
| it('reads a key kept on the installation', async () => { | ||
| await AgentInstallation.updateOne({ agentName: 'claude-code' }, | ||
| { $set: { runtimeTokens: [{ tokenHash: 'legacy-hash', lastUsedAt: new Date(Date.now() - 5000) }] } }); | ||
| const result = await ask(String(owner._id)); | ||
| expect(result.content.agents[0].state).toBe('active'); | ||
| }); | ||
|
|
||
| it('does not list another person\'s agents from other pods', async () => { | ||
| const result = await ask(String(new mongoose.Types.ObjectId())); | ||
| expect(result.content.agents).toEqual([]); | ||
| }); | ||
| }); |
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.