The Agent works with any Gnus back end including those, such as nnimap, that store flags (read, ticked, etc.) on the server. Sadly, the Agent does not actually know which backends keep their flags in the backend server rather than in .newsrc. This means that the Agent, while unplugged or disconnected, will always record all changes to the flags in its own files.
When you plug back in, Gnus will then check to see if you have any
changed any flags and ask if you wish to synchronize these with the
server. This behavior is customizable by
nil, the Agent will
never automatically synchronize flags. If it is
ask, which is
the default, the Agent will check if you made any changes and if so
ask if you wish to synchronize these when you re-connect. If it has
any other value, all flags will be synchronized automatically.
If you do not wish to synchronize flags automatically when you
re-connect, you can do it manually with the
gnus-agent-synchronize-flags command that is bound to J Y
in the group buffer.
Technical note: the synchronization algorithm does not work by “pushing”
all local flags to the server, but rather by incrementally updated the
server view of flags by changing only those flags that were changed by
the user. Thus, if you set one flag on an article, quit the group then
re-select the group and remove the flag; the flag will be set and
removed from the server when you “synchronize”. The queued flag
operations can be found in the per-server
flags file in the Agent
directory. It's emptied when you synchronize flags.