Posts

AWS Bedrock agentcore vs harness coding perspective

In bedrock agentcore, we have harness and runtime. We going to look at the code differences trying to invoke them. Whenever possible, ry to use 'bedrock-agentcore' as it is the newer package  atleast for now. Older library typically uses bedrock-agent-runtime . https://docs.aws.amazon.com/boto3/latest/reference/services/bedrock-agent-runtime.html Harness Notice that everything is the same except we need to update harnessArn and we invoke the method invoke_harness(). Notice we are instantiating 'bedrick-agentcore'. There's also a client called 'bedrock-agent-runtime. And when you see the word harness - you know you're in a good seat. :) import boto3 import json import uuid client = boto3.client( 'bedrock-agentcore' , region_name = 'ap-southeast-2' ) session_id = str (uuid.uuid4()) response = client.invoke_harness(     harnessArn = 'your-harness-arn' ,     runtimeSessionId = session_id,     messages = [         {     ...

aws bedrock runtime that integrates with your knowledge based

Image
 First of all we need to setup our knowledge base as shown here where we can specify the source of our knowledge.  Once we created it, we can referenced it in our code, next.  And these are the code that we can use to harness our knowledge base.  import boto3 client = boto3 . client ( "bedrock-agent-runtime" , region_name = "ap-southeast-2" ) # AgenticRetrieveStream - streaming, agent-driven multi-step retrieval response = client .agentic_retrieve_stream(     messages = [{ "role" : "user" , "content" : { "text" : "your query here" }}],     retrievers = [{ "configuration" : { "knowledgeBase" : { "knowledgeBaseId" : "YOUR-KNOWLEDGE-BASE-ID" }}}],     agenticRetrieveConfiguration = { "foundationModelType" : "MANAGED" , "maxAgentIteration" : 5 },     generateResponse = True , ) for event in response [ "stream" ]:     if "respons...

bedrock agentcore runtime getting started

Image
 Amazon Bedrock AgentCore Runtime is the serverless infrastructure layer that hosts custom agent code, pay for what you use while AgentCore Harness is a fully managed orchestration layer running on top of that runtime that builds the agent loop for you through simple configuration. Harness created runs and you will be billed for how long it is running. To get started with AgentCore runtime, we need to install it npm install -g @aws/agentcore agentcore --version Next, we will run the following in the root directory of the project (it must be in the root directory) :-  agentcore create --project-name MyTsAgent --no-agent cd MyTsAgent agentcore add agent --name TsAgent --type create --build CodeZip --language Python --framework Strands --model-provider Bedrock --memory none And to deploy it  agentcore deploy And we can see it in the console too To test it out  agentcore invoke "Tell me a joke" Or you can invoke it wth code :- import boto3 import json client = boto3.c...

azure application insights static metrics does not exsit trick

Remember when you're trying to create a static mertric ( azurerm_monitor_metric_aler t ), get it into terraform and when you deploy it, it failed because it does not exist in production. These metrics are not being sent into application insights via otel collector.  How do you get the metric setup in terraform? Instead of using the one above, we can use azurerm_monitor_scheduled_query_rules_alert to sett up the query instead.  Craft that in a way that even if the metric does not exist, we are still good. Then we can avoid this error when deployment to PROD.  

AWS Gateway API with REST API And Lambda setup

Image
To setup gateway API for your REST API, click on "Create API". Then click on "Build" Next, you will be prompted for these. Select "New API" and then TLS 1.3.  And then use default settings and click on "Create API". Then you click on "Create Method". Amd we will configure to point this service to our lamda function. Please ensure you have a lambda ready to go and then click " Create ".  You can easily test it out by clicking on "Test"  AWS gateway has this concept called Stage that basic define a REST API path, for example my server  https//myhost/dev and https//myhost/test   And let's say you created your REST API which has a path /hello then you references it via  https//myhost/dev/hello  and https//myhost/test/hello Here dev and test are called stage and that's where you need to deploy your application. API Key You can configure your REST API to ask for an API key  You can also add extra RESPONSE HEADER....

AWS Bedrock configuring intelligent prompt router

Image
We want to use bedrock intelligent prompt routing because we can send prompts to different foundational models within a model family, helping you optimize for quality of responses and cost. To do that,  goto "Prompt routing model".  Depending on the region, we are limited to AWS Nova and Llama.  Provide a name for your prompt router and then select relevant models. These are the list of models that your requested gets routed to. In this scenario, we are routing to Llama.   We also need to select a default route model, that will handle all responses if it is unable to determine where to route prompts to.  Click "Submt" when ready You can test it out by, click on "Action" ->  Open in playground If you want to access from "playground", you can do the following. Goto Playground -> Select Router under Categories. Then select your newly created routers.   

AWS bedrock inference profile basic setup and test

Image
Inference profile allow us to define and enforce data residency when processing request. You can setup these profile here by selecting "Infer" -> Inference Profile.  Under the application tab, click on "Create inference profile".  Next filled up your inference details and click "Create application inference profile". Please note that your model is limited to the region. To add more destination region, you need to use the API. And to use it, we can goto "Test" -> Playground and then "select model". Then please proceed to select your model and then click on "Inference" where you can choose your inference profiles. And that's how you can create and use your inference profile. 

Azure defender for contianer - enabling it

Image
We can enable Azure Defender for container by going to Microsoft Defender -> Environment Settings -> And then we will see the following screen. Here we can enable different feature by toggling button on or off.

Azure SAML App registration

Image
We can easily configure SAML app in Azure. Goto Enterprise Application ->  New Application. Then select "Create your own appllication". Provide a name and select "".  Click "create". After that you will be directed to the new app. Goto "Single sign on" and click on SAML.  And then click on "Edit" Provide the Identifer (a unique id) for your application.   Reply Url is the endpoint Entra will send the token to upon successful login.  Click on "Save".  You will be prompted to test this application. Click "Yes" to test the application.  So you will go through the standard process of signing into Entra - then you can see you will be redirected to http://lolcalhost:4000 with a SAML response. The SAML reponse is the token issued and you can validate that by using powerhell:- [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("YOUR_BASE64_STRING")) Next step, is to expose your REPLY URL ...

aws service control policies in organization - preventing user from creating s3 bucket in a region

Image
  For those coming from Azure, Aws account is a subscription. So in this walk-through we are going to create another new account called   with number xxxxxxxx . You would have another account which is the management account  ( yyyyyyyyyy ). SCP does not applies to the management yyyyyyyy account. Assuming you already have this AWS created and a user called "mark" who is tied to xxxxxx account.  Please note: The user from yyyyyy account are exempted To create your AWS service control policies, goto AWS Organization and then -> Policies -> Service Control Policies (please make sure you enable it)  Next, click on "Create policy" and add the following in the policy and click "create". { "Version": "2012-10-17", "Statement": [ { "Sid": "PreventS3CreationInApSoutheast1", "Effect": "Deny", "Action": [ "s3:CreateBucket" ], ...

affaan - everything claude code install opencode

Image
  Think everyone is execited about affaan's everything claude code. Let's setup this for opencode.  Please make sure you have nodejs installed. Then run the following command to get you setup  git clone https://github.com/affaan-m/ECC.git cd ECC npm install npm run build:opencode node scripts/ecc.js install --profile minimal --target opencode Next we will run opencode from command line, and you should be able to access your ecc here To start using follow this guide here https://github.com/affaan-m/ecc#start-using-ecc Some notes If you try to configure --profile to anything other than minimal, you will hit an issue and those instruction templates will not be installed.  What's next? We should start using it by running /ecc:plan "we are building android app with the latest kotlin and jetpack" . And you can see that it has provided quite a comprehensive instructions to the llm agent.  You can also run the following commands by going through the instructions ...

empero-ai/Qwen3.8-2B-Distill-GGUF Q4_K_M

Image
This is a good model and really fast too. Using the smaller size Q4_K_M and found out that it this version does not know how to call tool compare to its larger version empero-ai/Qwen3.8-4B-Distill-GGUF Switching to the Q_8 version aint any better. It still does not know how to call tools - the context given is way larger about 32k.  Then switching BF16 gives a context of 26.9k which is good but still unable to make any tool calling

ornith-ai/Ornith-1.0-9B-GGUF

Image
Loving this model, it is really good and able to do coding, perform web search and use edit tool to generate the necessary code. For example, if you ask it to write a hello world app in android, all these file are generated.  Really happy with it - it is fast and really usable. It does have a context of 11.5k for me which hopefully I can crank it up. 

unsloth studio - the output path or generated path when you enable code tool

The default path for unsloth studio path unsloth\studio\sandbox . For my case that will be :-  C:\Users\nzai\.unsloth\studio\sandbox\__LOCALID_ZQvj3Mq\android-app 

terraform tomap() requires some care when using it

Terraform tomap function requires the object to have the same schema otherwise it will give you the following error  │   on main.tf line 14, in resource "null_resource" "from_yaml_files": │   14:   for_each = tomap(local.yaml_data) │     ├──────────────── │     │ while calling tomap(v) │     │ local.yaml_data is object with 3 attributes │ │ Invalid value for "v" parameter: cannot convert object to map of any single type. Let's see what that looks like in yaml - if you're loading 3 files and all of them have the following - that's great! happy days. But if you have somehing that looks different  --- name : DisabledApp version : 0.5 enabled : false environment : development items :   - id : 1     type : test     name : test-service     port : 7000 different like this --- name : DisabledApp version : 0.5 enabled : false environment : development items :   - id : 1 ...