Agent restart frequency

Hello, I would like to know how often does an agent code restart/resets once we’re out of the developement phase and the api is just running

A Production Device’s agent will start when the unit it activated by an end-user via BlinkUp. The agent will stay active for as long as the device stays connected. If the device goes offline and stays that way for more than 30 days, the agent is stopped. It’s restarted when/if the device connects again.

That’s the basic lifecycle. However, we don’t guarantee that an agent will be running at any specific moment because agents may need to be migrated from one server to another for load-balancing, and that will require a brief (few seconds) stop/restart phase. You should code your application with this in mind.

More details here: Mitigating Agent Migrations | Dev Center

From experience, agent restarts are rare. I log all restarts on agents and they are few and far between. Occasionally, a server will be restarted or agents are migrated and there will be a brief flurry of restarts, but that’s it. They happen more often on the development servers than in production. Your code should be structured to expect it to happen at any time, without warning.
One absent feature on production I wish were there is the ability for the agent to query why it restarted, like you can on the device.
In terms of interruptions to service, it’s probably more important to be aware of disruptions to http, which happens more often. Only some of this could be attributed to stuff internal to Electric Imp, if at all. Outbound and inbound requests should always have some limited level of back-off & retry behaviour