-
Notifications
You must be signed in to change notification settings - Fork 191
api: implement GET /api/agents/:id to fix remote-mode welcome message #1047
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
base: main
Are you sure you want to change the base?
api: implement GET /api/agents/:id to fix remote-mode welcome message #1047
Conversation
…e in remote mode Signed-off-by: 26tanishabanik <[email protected]>
pkg/server/server.go
Outdated
| id := c.Param("id") | ||
|
|
||
| src, ok := s.sm.sources[id] | ||
| if !ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove a 404 if the id isn't found, we do have the /agents so the ID should be known
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the cagent with below command:
> ./bin/cagent api examples/welcome_message.yaml
Listening on [::]:8080
{"time":"2025-12-08T14:42:03.689901+05:30","id":"","remote_ip":"::1","host":"localhost:8080","method":"POST","uri":"/api/sessions","user_agent":"Go-http-client/1.1","status":200,"error":"","latency":841333,"latency_human":"841.333µs","bytes_in":228,"bytes_out":230}
Fetching agent with ID: examples/welcome_message.yaml
Agent found? false
{"time":"2025-12-08T14:42:03.691819+05:30","id":"","remote_ip":"::1","host":"localhost:8080","method":"GET","uri":"/api/agents/examples/welcome_message.yaml","user_agent":"Go-http-client/1.1","status":200,"error":"","latency":439000,"latency_human":"439µs","bytes_in":0,"bytes_out":736}
Fetching agent with ID: examples/welcome_message.yaml
Agent found? false
{"time":"2025-12-08T14:42:03.694068+05:30","id":"","remote_ip":"::1","host":"localhost:8080","method":"GET","uri":"/api/agents/examples/welcome_message.yaml","user_agent":"Go-http-client/1.1","status":200,"error":"","latency":216833,"latency_human":"216.833µs","bytes_in":0,"bytes_out":736}And then sent a request like this:
./bin/cagent run --remote http://localhost:8080 examples/welcome_message.yamlWithout the first !ok block, the welcome message doesn't come, do you want me to just remove the second !ok block? @rumpl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would actually need something like this: #1046
Basically it would seem that our urls are not defined as they should
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the code
…t instead of a separate agent by id endpoint and adds supporting unit test
This PR adds the missing GET /api/agents/:id, since the remote client already calls GetAgent and needs the exact config. Without it, remote mode can’t read welcome_message, hence the welcome never shows.
Fixes #973