Press "Enter" to skip to content

Agent and Agent Schedule in Pega

73

Introduction

In this post we will see in details about Agent and Agent Schedule in Pega.

Most of the applications rely on processes that operate at the background without human intervention.

Imagine there is a requirement to send a status report to the reporting manager every day by 8 p.m.

You can code it like ‘providing a button and by clicking on that, we send an email containing the status report’. But if you do like this people will laugh at you.

Here comes the Internal background process to provide solution for this requirement.

In Pega platform, ‘Agent’ rule serves as an Internal background process.

To know about requestor type involved in batch processing, please visit my post below.

http://myknowpega.com/2017/05/13/requestor-types/

Agent and Agent schedule in pega, both belongs to background processing

What is an Agent rule?

  • An agent is an internal background process operating in the server on a periodic basis.
  • Each agent rule can contain individual agent activities for different processes.
  • Agents come under SysAdmin category and each ruleset can contain only one Agent rule.

How to configure an Agent rule?

Agent rule don’t belong to any class.

In the Agent rule form, we have three main tabs.

  1. Schedule
  2. Security
  3. Nodes

Schedule tab:

a) Scheduled agents

In the scheduled agents, you can add ‘n’ number of activities.

Agent Name – Provides the name of the agent (Appropriate description).

Pattern          – Periodic/Recurring/Startup.

  • Periodic scenario: Imagine you need to update a work item every one hour. In the interval field, you specify the seconds as 3600.
  • Recurring scenario: You need to send mail daily at 1 pm. Use Interval field advanced option, to set the time daily to 1 pm.
  • Startup: Only when the server starts ( not used often).

Mode           – Standard / Advanced (We will have deep explanation below).

Category    – Not a required field. Use it for recording purpose.

Enable        – True/False. We can enable or disable the agent.

Class           – Class of the Agent activity rule.

Activity Name – Agent activity name.

Params – Activity parameters.

Max Records – Shows how many records the agent should process before going to sleep. Usually applicable  for standard agents.

Auto Queue Management – True/False.

What is Auto Queue Management (AQM)?

This is applicable only for standard agents.

Imagine a scenario where you need to update a work item in the background based on SLA.

The agent activity tries to acquire the lock for the work item, but is already locked by other agent. Now basically the agent activity cannot update the work item (fails). In this scenario, if

  • AQM is checked, then the agent re-queue the item for later processing.
  • If not checked, then the agent gets only one chance to process it and do not persist the queue item.

Agent wide settings

Enable this agent – True / False. Enable the Overall agent rule.

Interval – Default interval seconds. Used when if we don’t provide the Interval for Individual agent activity configurations.

Note: these configurations can be updated in agent & agent schedule

Security tab:

Access Group – Applicable only for Advanced agents. Used to identify the agent activity rule.

Access group -> Application -> Builds ruleset list -> Agent activity rule.

Bypass Authentication –  True / False – Agent activities may be configured to use authentication (Activity security tab). You can bypass those authentication by selecting true.

Nodes Tab:

We know Pega system can run on different nodes using different servers.

This tab lists the nodes, where the agent schedules are created. We will discuss about Agent schedule later in this post.

How a standard agent works?

Requirement: Route the Leave request case to manager queue for approval.

  • If the manager didn’t approve the next day, the send an Email to him.
  • Even after 3 days if he didn’t approve, then Auto-approve the request.

This requirement can be achieved using SLA on the assignment shape of manager queue.

As part of development, we just configure an SLA and don’t mind how the background SLA works.

I am going to take you to a trip and  explain in detail how the background SLA process works.

SLA process:

To know the basic of SLA, please visit my exclusive post on Service level agreement.

http://myknowpega.com/2017/05/17/service-level-agreement/

Front end:

  • When the Leave request case reaches the assignment shape Assign-.AddAssign gets called.

  • This activity queues an entry with Event as “goal” to agent “Pega-ProCom:ServiceLevelEvents”.
  • Expand 2nd & 3rd step to get the details.
  • Now the Goal event (1 day) is queued to standard agent.

Back end:

  • Agent – Pega-ProCom

  • System-Queue-ServiceLevel.EstablishContext is responsible for Open & lock the assignment and Switching the access group. (AQM functionality)
  • Process Event – SLA agent activity.

a) When the manager didn’t approve the next day

The agent activity runs and starts processing the queued Goal event. Use activity ExecuteSLA to set the Urgencies and execute the escalation activities. It Re-queues the entry again for Deadline event.

b) When the Manager didn’t approve for the third day

The agent activity runs and starts processing the queued Deadline event. Use ExecuteSLA to set the Urgencies and execute the escalation activities. Here no passed deadline, so no more queue entries are added again. Leave is auto approved after deadline.

Go through the activities ProcessEvent & EstablishContext in System-Queue-ServiceLevel class.

How an Advanced agent works?

Advanced agent do not automatically use the Auto Queue Management (AQM).

All the transaction items need to be carried out in agent activity. We can configure the activity to re-queue if some error occurs.

Key differences between Standard agent and advanced agent:

  1. Standard agent uses the access group of the user who queues the entry, while the advanced agent uses the access group specified in Agent rule or requestor type.
  2. Standard agent supports AQM, while advanced agent do not.
  3. Standard agent wake and run only when there are queue entries with available lock, while the advanced agent runs even if there are no queue entries. This is because advance agent is responsible for agent queue processing.

Issues you may face in advanced Agent:

Imagine the same scenario discussed above. You need to configure an agent to update a work item. Now you configured the agent as Advanced agent and made it available in 3 nodes. Here, Object contention occurs, since advanced agent activity should handle the locks. If the same is configured using Standard agent, then there won’t be any locking issue.

“Prefer using standard agent over advanced agent”.

What is Agent Schedule?

  • Here you can see the relation between agent and agent schedule in pega.
  • As we discussed before Agents can run in multi nodes.
  • Imagine a scenario where you need to update agent run Interval from 300 seconds to 30 seconds in particular node. To solve this Agent schedule comes in Handy.

  • Agent schedule is a data instance and can be updated in any environment.
  • Here Pattern, Interval, Enabled, Access group etc., are editable and can be updated for a particular node.
  • You can check the node ID in the ID header field.
  • The changes reflect immediately once updated and saved.

How to create Agent schedule?

There is no need to create the agent schedule manually. There is an OOTB Master agent which monitors the Agent rules. If there is any new agent rules or if there is any update the Master agent generates, then the appropriate agent is scheduled. This is the relation between agent and agent schedule in Pega 🙂

How to debug an agent?

Use SMA.

  • In the Agent management, you can check if the agent is running or not. If there is some error and the agent has stopped, then you can see the stack trace or log files.

  • Tracing the Requestor.

We may be aware of a mantra,

Stop -> start -> Delay -> go the requestor management and trace.

Have you ever wondered, why you do this?

Explanation:

  • As per my previous post, I mentioned Agents use batch requestor type.
  • Requestors will be assigned to agent activities, only when it runs. When agent runs, it requests a batch requestor.
  • So when you stop and start the agent, a new batch requestor (B) is assigned. You will delay and trace that requestor from requestor management page.

Hope you get the basics about agent and agent schedule in Pega

  1. Dhanu Dhanu

    Great read. One question- In multi node environment as the agent schedule instances are automatically how would agent activity run, would it run multiple times? What considerations have to be taken to avoid such contingencies.

    • prem prem

      Hi Dhanu,
      Good question.😊. Imagining you know the basics of multinode.
      In production we may have multinodes.

      Standard agent – we have AQM functionality right. It handles all the resource allocation. Say agents are available in 2 nodes. When agent in node A picks the queue item, it changes the status and starts processing. The agent in node B will never process the request. Don’t worry.. Pega handles it very well 😊.

      Legacy, advanced, standard with no AQM – we need to handle the browsing logic to pick the items.

      But.. but.. normally we use a single dedicated node for all the batch processing in Production environment. That is the recommended approach. So cool.

      You can restrict to particular node either through agent schedule or some command line scripts.
      Hope you are clear now😊

  2. Ramanareddy Ramanareddy

    HI Prem,

    Typically Agents are traced by SMA with stop –> start–> Delay approch. But case is here the configured agent will be run within 2 or 3 sec. How can you trace agent in this case

    • prem prem

      2 sec Agent. Omg 😀 . Bro you can increase the time frequency in the agent schedule. then Stop -> Start -> Delay

    • Mamta Mamta

      Agents minimum time is 5 seconds.You can never set it lesser than 5 seconds

  3. Saleem Saleem

    How can we trace the agent if SMA is down?

    • Premkumar G Premkumar G

      Hi Saleem,
      Tracer is available in 2 places. Designer studio and SMA.

      If SMA is down we have a single option. We don’t know the requestor ID the agent use to process.

      In dev environment, you can manually run and test the agent activity.

  4. Saikrishna Saikrishna

    Hi Prem,

    This is my first post in your bog after going through the Agents topic,its really great stuff you put .

    Can you explain me how we an configure SMA in personal edition
    (how to get Node Id details).

    Can u provide me real time example for split join ,sin off smart shapes with a example .

    Please keeping sharing more post on pega topics.

    • Premkumar G Premkumar G

      Hi Krishna,
      Thanks for the positive feedback.
      you can use Designer studio – > System -> General to find the node details. Please check in PDN to get those setup details.
      Exactly I am preparing my next post on Split Join, Split for Each, spin off scenarios 🙂

  5. Sai Sai

    Hi Prem,

    I read an article in PDN >>> https://pdn.pega.com/access-groups-agents#bckttp. (Please see Access groups on the Batch requestor record. Unable to paste the content here)
    My query is If we add “Access grop A” on Batch requestor record, and we added “Access group B” on our Agent rule.

    Which access group will be picked at run time to form the application stack.

    Thank You.

    • Premkumar G Premkumar G

      Hi Sai,
      For advanced agents, when the access group is not specified in the agent rule then the access group specified in the batch requestor comes effective 🙂

      The order of priority for access group is agent rule followed by batch requestors.

  6. Sai Sai

    Thank You Prem.

    • Premkumar G Premkumar G

      You are welcome, Sai 🙂

  7. Siva Siva

    Hi Prem,
    I have few questions on agents
    1. How Can we re queue an agent activity if it has errors?
    2. If server was down how can we know that we missed the agent execution and what can be done later to process the last run again?
    3. Agent Interval wake up time is 30 (correct me if im wrong) , what is the minimum interval time we can give ?

    • Premkumar G Premkumar G

      1. For standard agent, re-queuing occurs automatically when AQM is selected. Rarely, you can also use queue-for-agent to re-queue the entry, but its nor required since AQM can handles it.
      2. in production, this scenario is very rare. say you configured an agent to run 11 PM and the server was down that time. here the agent run will be missed. We can use some log message in the agent activity to identify if agent failed to run. I am not sure about the solution to run again. may be we can update the agent schedule !! :(. Can someone share their views
      3. The minimum default interval will be 5 seconds

  8. Kona Siva Kona Siva

    Hi Premier,
    1. If server is down during agent invocation time how we will know the details about the agent last run failure? How to requeue the last failure run?
    2. What is the min interval time we can give for agent run? it is 5sec (correct me if I’m wrong) can we give less than that?

    • Premkumar G Premkumar G

      1. In production, this scenario is very rare. say you configured an agent to run 11 PM and the server was down that time. here the agent run will be missed. We can use some log message in the agent activity to identify if agent failed to run. I am not sure about the solution to run again. may be we can update the agent schedule !! :(. Can someone share their views
      3. The default interval will be 5 seconds. there is no restriction. You can give less than 5 seconds 🙂

    • SaiRajesh SaiRajesh

      Hi Siva ,
      1.Usually in production environment there will be atleast two servers with a minimum of 2clones each . So if there is any server issues like hung threads ,high garbage. Utilization and if any clone stops loading alerts will be triggered and necessary action like recycle of was server clone will be performed and mean while whole work load is shared remaining clones .
      2. Also there are scenarios in which some agents are scheduled to run only in one clone of server and off in other clones. If due to issues clone / server is down then agents won’t run and it will be directly impact to business ,business comes with a ticket ,also the scheduled work of agent won’t be done and in logs we can get timestamp of interval when the agent was started and last run time as well . So there will be a backup like agent run in atleast 2 clones.

    • Sirisha Sirisha

      hi prem,
      earlier u only informed like agent min time interval should be 5sec. then y ur telling again we can give less than 5sec also? whicch one is correct?

  9. partha partha

    hi prem,

    how we can run one agent in multiple nodes and in single node multiple agents?

    • Premkumar G Premkumar G

      One agent in multiple nodes.
      We know that nodes share the common database and rule instances. So when you create a new agent rule, agent will be available in all nodes by default. You can make use of agent schedule to conditionally run the agent on selected nodes

      Single node multiple agents.
      You can configure agent rule per ruleset. Each agent can contain multiple agent activities. You can configure any activity as you wish 🙂

    • ishita ishita

      Hi Prem,
      I didnt understand the single node multiple agent scenario. If agent rules are created in different rulesets they will be available for other nodes too.

      Btw your articles are brilliant 😀

  10. Kumar Kumar

    Hi prem,
    Could you please explain how AQM can be leveraged to Advanced agents, as pega provides the AQM option for Advanced agents as well…

    • Premkumar G Premkumar G

      Hi Kumar,
      Though AQM option is visible in the advanced agents, it is of no use. AQM functionality is applicable only for standard agents

  11. AKR AKR

    hello prem
    u have furnished enough info in connect with AGENTS but you missed out few points
    you did not described about the significance of the
    Queue-for-agent method …how it works …does this method significantly required for both ADVANCED and STANDARD agents as well …..don’t think that am rookie and i don’t know fundamentals even ….my wish here is…. many rookies fallowing your blog by blindly trusting like no need to refer some other content ..even i would like your blog provide same as they expected ..that is the reason behind ‘am bringing this point here ..not only rookies for genuine experienced persons also very helpful as brush-up before attending any interview
    hope u understand my inclination 🙂
    your immediate response can help many people

  12. Rupesh Rupesh

    Hi Prem,

    There was some uncategorized category right?

    where it is now we are not able to see it.

    can you post it once again under some category.

    Thanks
    Rupesh M

    • Premkumar G Premkumar G

      Hi Rupesh, I moved the posts already under respective category. I didn’t delete any!!

  13. Bala Meenakshi Bala Meenakshi

    Hi Prem,

    Good post.!! Please keep up the good work.
    We also see AQM check box in Advanced agent type as well in agent rule. On checking the check box, will it behave same as Standard AQM check box.?

    • Premkumar G Premkumar G

      No Bala. AQM capability is applicable only for standard agents.

  14. pradeep pradeep

    Hi prem,
    please post the real time scenario on agents and agent schedule.

    Thank u very much

  15. Nilesh Saha Nilesh Saha

    Hi Prem,

    This is bry helpfull post.
    I have a question regatding advance agent.

    I have a advance agent and I have to create some requeue mechanism (as advance agent does not support AQM) with my own cusotm queue.How do we implement it ?
    It should also attempt to retry for a specified number of time from the queue.

    Thanks ,
    Nilesh

  16. Manasa Manasa

    Hi Prem,

    I have a query:
    How can we stop agent process on multiple nodes?

  17. Sai Sai

    Hi Prem,
    Your article is very helpful and gave me a clear understanding, but I just need one clarification.
    Is there any benefit of using advanced agent over standard agent.? If not, why is it categorised as Standard and advanced

    Thanks,
    Sai

  18. Nikhil Kumar Nikhil Kumar

    Hello Prem,
    Could you please help me to understand how to access group gets defined for the standard agent. I means when the standard agents checks the table pr_sys_queue for messages to get processed, how does the access group set for this agent run and how requestor helps in this process to identify the access group. Basically want to get the concepts clear for this methodology of Standard Agents.

  19. Manasa Manasa

    Hi Prem,

    I have a query:
    If we have 100 nodes and we need to stop the agent in 5 specific nodes.
    Could you please tell how this can be done.

    Thanks in Advance
    Manasa

  20. Arjun Arjun

    1. Can we use advanced agent for Queuing? If Yes, how can we achieve this?
    2. How locking mechanisim will work for Standard and Advanced agents? Please clarify. Thanks in Advance.
    Arjun

  21. naveen naveen

    Hi Prem,
    i have a question. if we create a customized queue inheriting from system-queue-. Then while using QueueForAgent method in an activity, how would pega know that the record should be inserted in our customized queue.
    1)Will it be sufficient if we make step page with that customized queue page or is there any other configuration which needs to be done.
    2)if making queue page as step page is sufficient, then if we want to queue any record related to Work Object(work class data). Then how we can configure because we may miss the context of user.

    I know this may take more lines to explain 🙂 . Thanks in Advance

  22. sujatha sujatha

    What is AgentBulkProcessing activity? How it works in case of standard agents?

  23. sujatha sujatha

    In Standard Agents, agent activity runs on work items which are in Queue.
    How that queue is loaded with work items?
    Is there any background activity runs to load that queue?
    What type of work items are loaded into queue?

  24. Rajasekhar Reddy Rajasekhar Reddy

    Nice Explanation Prem.
    I have one question, what is the difference between process driven and task driven agents?

  25. krishna krishna

    Can u share report Concepts.

    • Premkumar G Premkumar G

      Yeah, I’ll post about it soon. Stay tuned, Krishna. 🙂

  26. Preksha Preksha

    Hi,
    I want to know what is the use of ‘Start up’ agent pattern. When exactly do we choose ‘Startup’ as the pattern for an agent ?

    • PegaLearner PegaLearner

      Hi Prem,

      Can u please explain this ?

  27. Rajesh Rajesh

    HI Prem,

    Why we are creating std agent and advanced agent can you please explain?

  28. sameer sameer

    Hi prem ,
    I am getting very useful information in u r blog . Can u please post the topic on Single Sign on concept and some information on data table . if the SMA was down where we can trace this SSO etc information some more detailed .

    It really help ful for me

    • Premkumar G Premkumar G

      Hi Sameer,

      Glad to hear that you are finding my blog useful. I’ve taken note of that topic, Sameer. I’ll post about it soon. 🙂
      Stay tuned. 🙂

  29. Sai Sai

    Hi Prem,

    Thanks for the detailed explanation. I have a doubt. Suppose say we have a standard agent enabled on 2 different nodes, when the standard agent on first node tries to pick the first record, it changes the status of the record so the standard agent on different node does not pick and hence locking issues donot occur. Which status does pega change? Is it any pega related property? Can you please let me know if this cannot be handled by Advanced Agents?

  30. sanal sanal

    Hi Prem,

    What could be the possible reason that my agent activity is working explicitly when run manually, while from the agent it is not?

    • Premkumar G Premkumar G

      Hi sanal, can you provide more details.
      1. Is it a standard or advanced agent.
      2. Did you check SMA, if its running or not.
      3. Check if require authentication us checked it not in agent rule and agent activity rule.

  31. Sai Venu Sai Venu

    Hi Prem,
    Can you please show some example for how to handle locking in ADVANCE AGENTS, as in STANDARD AGENTS, PRPC will be taken care, so how we explicitly taken care for ADVANCED AGENTS

  32. dilep dilep

    Hi pream ,

    i am getting confusued .we have a bussines requirment like this i have to send email EOD every day .we can use advanced agent to achieve this ? are we can do this for standard agent? if yes how ? please let me know .

    Thnaks In Advance .

  33. Swaroop Swaroop

    Hi Prem,

    This is an excellent work… really awesome

    I have been trying to learn agents in details. I got a excellent information from your post. Thanks for this.

    But I am posting some questions which I have faced in recent interviews. I would be really great if you can help me out.

    Q1. The scenario I have is: We have an agent. We want this agent to run every 5min between morning 9 to 10 Clock and after that we want the same agent to run every 1 hour. How can we achieve this.

    Q2. How can we automate monitor the status of an agent? The requirement is we need to automatically be updated in case there is any failure of an agent ?

    Q3. How to debug an agent when we do not have access to SMA?

    Q4. I have a standard agent activity ‘WriteToLocalFile’ which writes a file to local disk. This activity is in my Work Class: Tata-Finance-Work. Because my activity is not under System-Queue- class, will not my agent be queued?

    Q5. I have an advance agent with access group ‘A’. Is it possible to change the access group of this agent? If yes, how can we change it?

    Q6. If a standard agent fails it will be seen under broken-queue? What happens when advanced agent fails? Where can we see it?

    Q7. Using Agent we run 10 WO’s and from this 5 WO’s fails how can we know this information?

    I know I have a big list of questions. I am posting as it may be useful for other also.

    Thanks in advance Prem

  34. Naveen D Naveen D

    Hi Prem

    Appreciate your efforts and passion towards the technology.

    Could you please help me with the below query:

    Why should we have only one agent in a ruleset?
    I tried creating two agents in a ruleset. Its allowing me to create. Kindly advice.

  35. Sumit Sumit

    Hi Prem,
    When we use QueueForAgent for queing a workobject, how do we configure that the work object queues to a particular class. i.e how can we customise the class where it will be queued?

  36. Ram Ram

    agent normal pick the records from some table , how we need to customise to our own table?

  37. Sarath Prashanth Sarath Prashanth

    Hi Prem,

    How is queue for agent linked with our standard agent queue ?
    -Sarath

  38. Kumar Kumar

    Hi Prem,
    How items are getting pushed into Queue table.
    for Advanced agents we’ll use Queue-For-Agents method
    but in standard agents how it is going to happen???

  39. gaurab gaurab

    Hi Prem,
    This is very good piece of information on Agents, I also read your other posts. Thanks a lot for sharing such useful information on Pega.
    In Case of Advanced agents, can you please elaborate about the transactions which you have mentioned need to be handled n the agent activity? What transactions you are talking about? Please explain with example.

  40. sreekar sreekar

    Hi Prem ,

    As per the above posts AQM option for Advanced is no use

    What purpose AQM option is available in Advanced agent even though there is no use of it. And which scenario can we use Advanced agents.

    Thanks
    Sreekar

  41. Harsh Soni Harsh Soni

    Hi Prem,

    I am regular reader of your blog and topics are always explained neatly and in a easy manner , it is great stuff you put. Keep this work going on as this is benefiting many of us. I would request you to make a post about Node in Pega and how those nodes are created and some what about load balancing.

  42. Shyam Prasad Shyam Prasad

    Hi,

    Why agents run on a different thread ? why its not running on the same thread?

  43. Mahesh Mahesh

    Hi Prem,
    Can you tell me any real time examples when to use Standard agent and Advanced Agents?
    Thanks
    Mahesh

  44. Shaik Nayab Rasool Shaik Nayab Rasool

    Hi Prem,
    Without SMA, Without Log Files,Without Logging in to developer Portal ,Is there any way to see the Agent Failure status.

  45. naresh d naresh d

    hai, prem,

    what is the use of “queue -for-agent” method? can you please explain briefly..

    thank you

  46. Akash Akash

    Hi Prem,

    I am facing agent hung state. I mean after some time agents are automatically went to hung state though on SMA it is green tick marked.They are actually stuck after some time. Post restarting they are working fine but again after some time period they get stuck.
    NOTE: ALL NODES SHOWS SAME BEHAVIOUR.

    Please advise resolution for this.

    Thanks,
    Akash

  47. aaron aaron

    hi! i am trying to figure out how to get an approve step to automatically approve when the deadline passes. i am sorry to say that i am still not sure if this article is intended to explain how to do that or not. you mention automatic approval as a requirement in a scenario you describe, but how to go about making it happen is not clear to me at all. what am i missing? do i need to change some out-of-the-box Pega activity and make my own special version just for that? if so, what do i change? i looked through the steps in the activities you specifically mention and it was not at all obvious to me. and if i really have to go to all that trouble, then wow, why does Pega take something that sounds so simple and make you beat it with a sledgehammer to get it to work? surely there should be a much simpler way to do this, with everything else that Pega is supposed to simplify for the application developer? please help?

  48. Mounika Mounika

    Hi Prem,
    How can we know the last run time of Particular agent?Any table hold that details?
    So that can be captured and Used for Processing records or Cases that are not updated from last Run.

  49. Vikranth Vikranth

    Hi Pem,

    This content is really good and helpful.

    Running Advanced Agent for processing 100k records is consuming lot of time. Can we run advanced agent on multiple nodes to increase process time. If so, how ? If we can’t run, why?

  50. Devika Devika

    How can we make advanced agent to run in multiple nodes.? (I think question is correct)

  51. Ratna Ratna

    Hi Prem,

    1.wt is queue for agent
    2.how to add nodes in agent

  52. Debraj Debraj

    Nice article Prem , you are doing a great Job.

  53. Santhoshi Santhoshi

    I am getting good information from you posts. Keep posting more PEGA topics.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!